mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
#120: hide popup on esc key press
This commit is contained in:
@@ -105,4 +105,63 @@ describe('<PopupStack />', () => {
|
||||
|
||||
sinon.assert.notCalled(props.destroy);
|
||||
});
|
||||
|
||||
it('should hide popup, when esc pressed', () => {
|
||||
const props = {
|
||||
destroy: sinon.stub(),
|
||||
popups: [
|
||||
{
|
||||
Popup: DummyPopup
|
||||
}
|
||||
]
|
||||
};
|
||||
mount(<PopupStack {...props} />);
|
||||
|
||||
const event = new Event('keyup');
|
||||
event.which = 27;
|
||||
document.dispatchEvent(event);
|
||||
|
||||
sinon.assert.calledOnce(props.destroy);
|
||||
});
|
||||
|
||||
it('should hide first popup in stack', () => {
|
||||
const props = {
|
||||
destroy: sinon.stub(),
|
||||
popups: [
|
||||
{
|
||||
Popup() {return null;}
|
||||
},
|
||||
{
|
||||
Popup: DummyPopup
|
||||
}
|
||||
]
|
||||
};
|
||||
mount(<PopupStack {...props} />);
|
||||
|
||||
const event = new Event('keyup');
|
||||
event.which = 27;
|
||||
document.dispatchEvent(event);
|
||||
|
||||
sinon.assert.calledOnce(props.destroy);
|
||||
sinon.assert.calledWithExactly(props.destroy, props.popups[1]);
|
||||
});
|
||||
|
||||
it('should NOT hide popup on esc pressed if disableOverlayClose', () => {
|
||||
const props = {
|
||||
destroy: sinon.stub(),
|
||||
popups: [
|
||||
{
|
||||
Popup: DummyPopup,
|
||||
disableOverlayClose: true
|
||||
}
|
||||
]
|
||||
};
|
||||
mount(<PopupStack {...props} />);
|
||||
|
||||
const event = new Event('keyup');
|
||||
event.which = 27;
|
||||
document.dispatchEvent(event);
|
||||
|
||||
sinon.assert.notCalled(props.destroy);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user