Allowing Privacy Policy link click to happen with modifier key

This commit is contained in:
Jeff Avallone 2019-01-18 16:33:02 -05:00
parent 2c8b779793
commit 1bb01ab8eb
2 changed files with 18 additions and 0 deletions

View File

@ -26,6 +26,10 @@ class Header extends React.PureComponent {
}
handleOpen = event => {
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) {
return;
}
event.preventDefault();
this.setState({ showModal: true });
}

View File

@ -30,6 +30,20 @@ describe('Header', () => {
expect(component).toMatchSnapshot();
});
['shift', 'ctrl', 'alt', 'meta'].forEach(key => {
test(`opening the Privacy Policy modal while holding ${ key } key`, () => {
const component = shallow(
<Header banner={ false } />
);
const eventObj = { preventDefault: jest.fn() };
component.instance().handleOpen({ [key + 'Key']: true, ...eventObj });
expect(eventObj.preventDefault).not.toHaveBeenCalled();
expect(component.state('showModal')).toEqual(false);
});
});
test('closing the Privacy Policy modal', () => {
const component = shallow(
<Header banner={ false } />