Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Mar 31, 2023
1 parent 9597341 commit 0231926
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/

import { render } from '@testing-library/react'
import { fireEvent, render } from '@testing-library/react'
import React from 'react'
import {
mount,
Expand Down Expand Up @@ -235,6 +235,19 @@ describe('ToggleButton component', () => {
)
})

it('should support enter key', () => {
const onChange = jest.fn()
render(<Component on_change={onChange} />)

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(<Component top="2rem" />)

Expand Down

0 comments on commit 0231926

Please sign in to comment.