From d56bc106772975a6433ed646c8cd122095dfde31 Mon Sep 17 00:00:00 2001 From: jzh <1587315093@qq.com> Date: Tue, 4 Jul 2023 14:38:55 +0800 Subject: [PATCH] test: add click case --- src/components/radio/tests/radio.test.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/radio/tests/radio.test.tsx b/src/components/radio/tests/radio.test.tsx index 40e8d99920..78046c9154 100644 --- a/src/components/radio/tests/radio.test.tsx +++ b/src/components/radio/tests/radio.test.tsx @@ -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` @@ -22,7 +21,16 @@ describe('Radio', () => { expect(radio).toBeChecked() expect(label).toHaveClass(`${classPrefix}-checked`) }) + test('Radio click ', async () => { + const handleClick = jest.fn() + render(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(