Skip to content

Commit

Permalink
test(popup-menu): group <Escape> handling specs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Nov 22, 2022
1 parent e4383b6 commit c91bc8e
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions test/spec/features/popup-menu/PopupMenuComponentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,36 +301,40 @@ describe('features/popup-menu - <PopupMenu>', function() {
}));


it('should close with <Escape>', inject(function() {
describe('should close with <Escape>', function() {

// given
const onClose = sinon.spy();
createPopupMenu({ container, entries, onClose, search: true });
it('on search', inject(function() {

const searchInput = domQuery('.djs-popup-search input', container);
// given
const onClose = sinon.spy();
createPopupMenu({ container, entries, onClose, search: true });

// when
searchInput.dispatchEvent(keyDown('Escape'));
const searchInput = domQuery('.djs-popup-search input', container);

// then
expect(onClose).to.be.calledOnce;
}));
// when
searchInput.dispatchEvent(keyDown('Escape'));

// then
expect(onClose).to.be.calledOnce;
}));

it('should close on global <Escape>', inject(async function() {

// given
const onClose = sinon.spy();
createPopupMenu({ container, entries, onClose });
it('global', inject(async function() {

await whenStable();
// given
const onClose = sinon.spy();
createPopupMenu({ container, entries, onClose });

// when
document.documentElement.dispatchEvent(keyDown('Escape'));
await whenStable();

// then
expect(onClose).to.be.calledOnce;
}));
// when
document.documentElement.dispatchEvent(keyDown('Escape'));

// then
expect(onClose).to.be.calledOnce;
}));

});


it('should navigate with <ArrowDown>', inject(async function() {
Expand Down

0 comments on commit c91bc8e

Please sign in to comment.