Skip to content

Instantly share code, notes, and snippets.

@millnitzluan
Created May 21, 2020 21:04
Show Gist options
  • Select an option

  • Save millnitzluan/8bb6667b7aacb382bc8622058ed0bde9 to your computer and use it in GitHub Desktop.

Select an option

Save millnitzluan/8bb6667b7aacb382bc8622058ed0bde9 to your computer and use it in GitHub Desktop.
test
const event_one = new Event('event_one');
const event_two = new Event('event_two');
const dispatch() => () => document.dispatchEvent(event_two);
describe('test dispatch', () => {
it('should dispatch event one', () => {
document.dispatchEvent = jest.fn();
dispatch();
expect(document.dispatchEvent).toHaveBeenCalledWith(event_one) // true
expect(document.dispatchEvent).toHaveBeenCalledWith(event_two) // true
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment