@@ -8,10 +8,10 @@ describe('Dropdown Component', () => {
88 const { container : { children : [ div ] } , queryByText } = render (
99 < Dropdown > < div > Child 1</ div > < div > Child 2</ div > </ Dropdown >
1010 )
11- expect ( div ?. classList ) . not . toContain ( styles . open )
11+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' )
1212 expect ( queryByText ( 'Child 1' ) ) . toBeDefined ( )
1313 expect ( queryByText ( 'Child 2' ) ) . toBeDefined ( )
14- expect ( div ?. classList ) . not . toContain ( styles . dropdownLeft )
14+ expect ( div ?. classList ) . toContain ( styles . dropdownLeft )
1515 } )
1616
1717 it ( 'toggles dropdown content on button click' , ( ) => {
@@ -23,11 +23,11 @@ describe('Dropdown Component', () => {
2323 fireEvent . click ( dropdownButton )
2424
2525 // Check if dropdown content appears
26- expect ( div ?. classList ) . toContain ( styles . open )
26+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
2727
2828 // Click again to close
2929 fireEvent . click ( dropdownButton )
30- expect ( div ?. classList ) . not . toContain ( styles . open )
30+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' )
3131 } )
3232
3333 it ( 'closes dropdown when clicking outside' , ( ) => {
@@ -37,11 +37,11 @@ describe('Dropdown Component', () => {
3737
3838 const dropdownButton = getByRole ( 'button' )
3939 fireEvent . click ( dropdownButton ) // open dropdown
40- expect ( div ?. classList ) . toContain ( styles . open )
40+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
4141
4242 // Simulate a click outside
4343 fireEvent . mouseDown ( document )
44- expect ( div ?. classList ) . not . toContain ( styles . open )
44+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' )
4545 } )
4646
4747 it ( 'does not close dropdown when clicking inside' , ( ) => {
@@ -51,12 +51,12 @@ describe('Dropdown Component', () => {
5151
5252 const dropdownButton = getByRole ( 'button' )
5353 fireEvent . click ( dropdownButton ) // open dropdown
54- expect ( div ?. classList ) . toContain ( styles . open )
54+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
5555
5656 const dropdownContent = getByText ( 'Child 1' ) . parentElement
5757 if ( ! dropdownContent ) throw new Error ( 'Dropdown content not found' )
5858 fireEvent . mouseDown ( dropdownContent )
59- expect ( div ?. classList ) . toContain ( styles . open )
59+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
6060 } )
6161
6262 it ( 'closes dropdown on escape key press' , ( ) => {
@@ -66,11 +66,11 @@ describe('Dropdown Component', () => {
6666
6767 const dropdownButton = getByRole ( 'button' )
6868 fireEvent . click ( dropdownButton ) // open dropdown
69- expect ( div ?. classList ) . toContain ( styles . open )
69+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' )
7070
7171 // Press escape key
7272 fireEvent . keyDown ( document , { key : 'Escape' , code : 'Escape' } )
73- expect ( div ?. classList ) . not . toContain ( styles . open )
73+ expect ( div ?. children [ 0 ] ?. getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' )
7474 } )
7575
7676 it ( 'adds dropdownLeft class when align is left' , ( ) => {
0 commit comments