Skip to content

Commit 782d673

Browse files
committed
test(collapsible): test aria-controls behavior
1 parent 2eddc8d commit 782d673

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/react/collapsible/src/Collapsible.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ describe('given a default Collapsible', () => {
4848
});
4949
});
5050
});
51+
52+
it('should not have an aria-controls attribute', () => {
53+
expect(trigger.getAttribute('aria-controls')).toBeNull();
54+
});
5155
});
5256

5357
describe('given an open uncontrolled Collapsible', () => {
@@ -100,4 +104,11 @@ describe('given an open controlled Collapsible', () => {
100104
expect(content).toBeVisible();
101105
});
102106
});
107+
108+
it('should have a valid aria-controls attribute', () => {
109+
const trigger = rendered.getByText(TRIGGER_TEXT);
110+
const ariaControls = trigger.getAttribute('aria-controls');
111+
expect(ariaControls).not.toBeNull();
112+
expect(ariaControls).toBe(content.id);
113+
});
103114
});

0 commit comments

Comments
 (0)