diff --git a/packages/dnb-eufemia/src/components/toggle-button/__tests__/ToggleButton.test.tsx b/packages/dnb-eufemia/src/components/toggle-button/__tests__/ToggleButton.test.tsx index 07d81956e97..19e7fab1592 100644 --- a/packages/dnb-eufemia/src/components/toggle-button/__tests__/ToggleButton.test.tsx +++ b/packages/dnb-eufemia/src/components/toggle-button/__tests__/ToggleButton.test.tsx @@ -3,7 +3,7 @@ * */ -import { render } from '@testing-library/react' +import { fireEvent, render } from '@testing-library/react' import React from 'react' import { mount, @@ -235,6 +235,19 @@ describe('ToggleButton component', () => { ) }) + it('should support enter key', () => { + const onChange = jest.fn() + render() + + const element = document.querySelector('button') + + fireEvent.keyDown(element, { keyCode: 13 }) // enter + expect(onChange).toHaveBeenCalledTimes(1) + + fireEvent.keyUp(element, { keyCode: 13 }) // enter + expect(onChange).toHaveBeenCalledTimes(2) + }) + it('should support spacing props', () => { render()