angular2-hotkeys icon indicating copy to clipboard operation
angular2-hotkeys copied to clipboard

how to unit test?

Open chr1soscl opened this issue 5 years ago • 1 comments

How can I unit test this piece of code? I cannot find any example on how I can unit test this:


 this.hotkeysService.add(new Hotkey('ctrl+shift+t', (event: KeyboardEvent): boolean => {
       //my actions
        return false; // Prevent bubbling
      }));

chr1soscl avatar Oct 16 '19 20:10 chr1soscl

Not really familiar with any easy way to do unit tests that emulate keyboard presses. But you could probably create a mock hotkeysService that you inject into your component or service and verify that the hotkeys you expect are registered. I think that's the best option I can think of at the moment.

wittlock avatar Nov 14 '19 20:11 wittlock