Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

45 lines
1.2 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ShortcutService, ShortcutServiceFactory } from './shortcut.service';
describe('ShortcutService', () => {
it('should instantiate from factory', () => {
const shortcutService = ShortcutServiceFactory();
expect(shortcutService).toBeDefined();
});
it('should instantiate', () => {
const shortcutService = new ShortcutService();
expect(shortcutService).toBeDefined();
});
it('should raise event when triggered', () => {
const shortcutService = new ShortcutService();
let isTriggered = false;
shortcutService.on('ctrl+a', () => { isTriggered = true; });
shortcutService.trigger('ctrl+a');
expect(isTriggered).toBeTruthy();
});
it('should not raise event when triggered but unsubscribed', () => {
const shortcutService = new ShortcutService();
let isTriggered = false;
shortcutService.on('ctrl+a', () => { isTriggered = true; });
shortcutService.off('ctrl+a');
shortcutService.trigger('ctrl+a');
expect(isTriggered).toBeFalsy();
});
});