Skip to content

Commit

Permalink
test(dropdown): add unit test for controlled visible prop
Browse files Browse the repository at this point in the history
  • Loading branch information
ousiri committed Jan 24, 2022
1 parent 4ec4af2 commit a23c76f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ describe('dropdown', () => {
expect(dropdown.find('.my-button').hasClass('rc-dropdown-open')).toBe(true);
});

it('supports constrolled visible prop', () => {
const onVisibleChange = jest.fn();
const dropdown = mount(
<Dropdown
overlay={<div className="check-for-visible">Test</div>}
visible
trigger={['click']}
onVisibleChange={onVisibleChange}
>
<button className="my-button">open</button>
</Dropdown>,
);
expect(getPopupDomNode(dropdown) instanceof HTMLDivElement).toBeTruthy();
expect(dropdown.find('.my-button').hasClass('rc-dropdown-open')).toBe(true);

dropdown.find('.my-button').simulate('click');
expect(onVisibleChange).toHaveBeenCalledWith(false);
});

it('simply works', async () => {
let clicked;
let overlayClicked;
Expand Down

0 comments on commit a23c76f

Please sign in to comment.