Skip to content

Commit

Permalink
test: add click case
Browse files Browse the repository at this point in the history
  • Loading branch information
1587315093 committed Jul 4, 2023
1 parent 46963a8 commit d56bc10
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/radio/tests/radio.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { fireEvent, render, testA11y, userEvent, screen } from 'testing'
import Radio from '../'
import { RadioGroupProps } from '../group'

const classPrefix = `adm-radio`

Expand All @@ -22,7 +21,16 @@ describe('Radio', () => {
expect(radio).toBeChecked()
expect(label).toHaveClass(`${classPrefix}-checked`)
})
test('Radio click ', async () => {
const handleClick = jest.fn()
render(<Radio onClick={handleClick}>Radio</Radio>)

const label = document.getElementsByTagName('label')[0]
expect(label).toHaveClass(`${classPrefix}`)

fireEvent.click(label)
expect(handleClick).toBeCalledTimes(1)
})
test('onChange should be call once when the selected item is clicked multiple times', async () => {
const onChange = jest.fn()
render(
Expand Down

0 comments on commit d56bc10

Please sign in to comment.