Skip to content

Commit 20f8b27

Browse files
committed
Add some extra tests
1 parent 44dff6b commit 20f8b27

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/use-dropdown-menu.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,24 @@ it('moves the focus to the menu button after pressing escape while focused on a
119119
firstMenuItem.simulate('keydown', { key: 'Escape' });
120120
expect(document.activeElement?.id).toBe('menu-button');
121121
});
122+
123+
it('opens the menu after clicking the button', () => {
124+
const component = mount(<TestComponent />);
125+
const button = component.find('#menu-button');
126+
const span = component.find('#is-open-indicator');
127+
128+
button.simulate('click');
129+
130+
expect(span.text()).toBe('true');
131+
});
132+
133+
it('closes the menu after clicking the button when the menu is open', () => {
134+
const component = mount(<TestComponent />);
135+
const button = component.find('#menu-button');
136+
const span = component.find('#is-open-indicator');
137+
138+
button.simulate('click');
139+
button.simulate('click');
140+
141+
expect(span.text()).toBe('false');
142+
});

0 commit comments

Comments
 (0)