Skip to content

Commit

Permalink
test(collapsible): test aria-controls behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dodomorandi committed Jan 13, 2025
1 parent 6bb71d0 commit 65a696b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/react/collapsible/src/Collapsible.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe('given a default Collapsible', () => {
});
});
});

it('should not have an aria-controls attribute', () => {
expect(trigger.getAttribute('aria-controls')).toBeNull();
});
});

describe('given an open uncontrolled Collapsible', () => {
Expand Down Expand Up @@ -100,4 +104,11 @@ describe('given an open controlled Collapsible', () => {
expect(content).toBeVisible();
});
});

it('should have a valid aria-controls attribute', () => {
const trigger = rendered.getByText(TRIGGER_TEXT);
const ariaControls = trigger.getAttribute('aria-controls');
expect(ariaControls).not.toBeNull();
expect(ariaControls).toBe(content.id);
});
});

0 comments on commit 65a696b

Please sign in to comment.