Skip to content

Commit

Permalink
fix: added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
roennibus authored Jun 7, 2022
1 parent e66063e commit f6d326c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions projects/ngneat/hotkeys/src/lib/tests/hotkeys.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,23 @@ describe('Service: Sequence Hotkeys', () => {

return run();
});

it('should call callback after clearing and adding sequence shortcut', () => {
const run = async () => {
// * Need to space out time to prevent other test keystrokes from interfering with sequence
await sleep(250);
const spyFcn = createSpy('subscribe', (...args) => {});
spectator.service.addSequenceShortcut({ keys: 'g>h' }).subscribe();
spectator.service.removeShortcuts('g>h');
spectator.service.addSequenceShortcut({ keys: 'g>j' }).subscribe();
spectator.service.onShortcut(spyFcn);
fakeKeyboardSequencePress(['g', 'j']);
await sleep(250);
expect(spyFcn).toHaveBeenCalled();
};

return run();
});

it('should add sequence shortcut', () => {
spectator.service.addSequenceShortcut({ keys: 'g>i' }).subscribe();
Expand Down

0 comments on commit f6d326c

Please sign in to comment.