Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('dispatches the event via the KeymapManager and CommandRegistry', () => {
const dispatchedCommands = [];
atom.commands.onWillDispatch(command => dispatchedCommands.push(command));
atom.commands.add('*', { 'foo-command': () => {} });
atom.keymaps.add('source-name', { '*': { x: 'foo-command' } });
const event = KeymapManager.buildKeydownEvent('x', {
target: document.createElement('div')
});
document.dispatchEvent(event);
expect(dispatchedCommands.length).toBe(1);
expect(dispatchedCommands[0].type).toBe('foo-command');
}));