Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
m4theushw committed Apr 6, 2021
1 parent e7a5fbb commit 36b249b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/e2e/fixtures/ClickAwayListener/WithSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import ClickAwayListener from '@material-ui/core/ClickAwayListener';

export default function WithSelect() {
const [clickedAway, setClickedAway] = React.useState(false);

return (
<React.Fragment>
<div>{clickedAway ? 'onClickAway called' : null}</div>
<ClickAwayListener onClickAway={() => setClickedAway(true)}>
<Select value="">
<MenuItem value={10}>One</MenuItem>
<MenuItem value={20}>Two</MenuItem>
<MenuItem value={30}>Three</MenuItem>
</Select>
</ClickAwayListener>
</React.Fragment>
);
}
9 changes: 9 additions & 0 deletions test/e2e/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@ describe('e2e', () => {
expect(await page.evaluate(() => document.activeElement?.textContent)).to.equal('ok');
});
});

describe('<ClickAwayListener />', () => {
it('should not call onClickAway when opening a select', async () => {
await renderFixture('ClickAwayListener/WithSelect');
await page.click('[role="button"]');
await page.click('text=One');
expect(await page.$('text=onClickAway called')).to.equal(null);
});
});
});

0 comments on commit 36b249b

Please sign in to comment.