@@ -3,46 +3,46 @@ import { render, screen, fireEvent } from '@testing-library/react';
33import RadioPrimitive from '../index' ;
44
55describe ( 'RadioPrimitive' , ( ) => {
6- const baseProps = {
7- name : 'test-radio' ,
8- value : 'option1' ,
9- id : 'radio1' ,
10- } ;
6+ const baseProps = {
7+ name : 'test-radio' ,
8+ value : 'option1' ,
9+ id : 'radio1'
10+ } ;
1111
12- it ( 'renders with required props' , ( ) => {
13- render ( < RadioPrimitive { ...baseProps } /> ) ;
14- const radio = screen . getByRole ( 'radio' ) ;
15- expect ( radio ) . toBeInTheDocument ( ) ;
16- expect ( radio ) . toHaveAttribute ( 'name' , 'test-radio' ) ;
17- expect ( radio ) . toHaveAttribute ( 'value' , 'option1' ) ;
18- expect ( radio ) . toHaveAttribute ( 'id' , 'option1 ' ) ;
19- } ) ;
12+ it ( 'renders with required props' , ( ) => {
13+ render ( < RadioPrimitive { ...baseProps } /> ) ;
14+ const radio = screen . getByRole ( 'radio' ) ;
15+ expect ( radio ) . toBeInTheDocument ( ) ;
16+ expect ( radio ) . toHaveAttribute ( 'name' , 'test-radio' ) ;
17+ expect ( radio ) . toHaveAttribute ( 'value' , 'option1' ) ;
18+ expect ( radio ) . toHaveAttribute ( 'id' , 'radio1 ' ) ;
19+ } ) ;
2020
21- it ( 'applies checked, required, and disabled props' , ( ) => {
22- render (
23- < RadioPrimitive { ...baseProps } checked required disabled />
24- ) ;
25- const radio = screen . getByRole ( 'radio' ) ;
26- expect ( radio ) . toBeChecked ( ) ;
27- expect ( radio ) . toBeRequired ( ) ;
28- expect ( radio ) . toBeDisabled ( ) ;
29- expect ( radio ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
30- expect ( radio ) . toHaveAttribute ( 'aria-required' , 'true' ) ;
31- } ) ;
21+ it ( 'applies checked, required, and disabled props' , ( ) => {
22+ render (
23+ < RadioPrimitive { ...baseProps } checked required disabled />
24+ ) ;
25+ const radio = screen . getByRole ( 'radio' ) ;
26+ expect ( radio ) . toBeChecked ( ) ;
27+ expect ( radio ) . toBeRequired ( ) ;
28+ expect ( radio ) . toBeDisabled ( ) ;
29+ expect ( radio ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
30+ expect ( radio ) . toHaveAttribute ( 'aria-required' , 'true' ) ;
31+ } ) ;
3232
33- it ( 'calls onChange when clicked' , ( ) => {
34- const handleChange = jest . fn ( ) ;
35- render (
36- < RadioPrimitive { ...baseProps } onChange = { handleChange } />
37- ) ;
38- const radio = screen . getByRole ( 'radio' ) ;
39- fireEvent . click ( radio ) ;
40- expect ( handleChange ) . toHaveBeenCalled ( ) ;
41- } ) ;
33+ it ( 'calls onChange when clicked' , ( ) => {
34+ const handleChange = jest . fn ( ) ;
35+ render (
36+ < RadioPrimitive { ...baseProps } onChange = { handleChange } />
37+ ) ;
38+ const radio = screen . getByRole ( 'radio' ) ;
39+ fireEvent . click ( radio ) ;
40+ expect ( handleChange ) . toHaveBeenCalled ( ) ;
41+ } ) ;
4242
43- it ( 'supports asChild prop (renders without error)' , ( ) => {
44- render ( < RadioPrimitive { ...baseProps } asChild /> ) ;
45- const radio = screen . getByRole ( 'radio' ) ;
46- expect ( radio ) . toBeInTheDocument ( ) ;
47- } ) ;
43+ it ( 'supports asChild prop (renders without error)' , ( ) => {
44+ render ( < RadioPrimitive { ...baseProps } asChild /> ) ;
45+ const radio = screen . getByRole ( 'radio' ) ;
46+ expect ( radio ) . toBeInTheDocument ( ) ;
47+ } ) ;
4848} ) ;
0 commit comments