@whatwg-node/events 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @whatwg-node/events
2
2
 
3
+ ## 0.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c0d5c43`](https://github.com/ardatan/whatwg-node/commit/c0d5c43a1c4d3d9fcdf542472fabdebd5118fe23) Thanks [@ardatan](https://github.com/ardatan)! - Fix dispatchEvent on Node 14
8
+
3
9
  ## 0.0.1
4
10
 
5
11
  ### Patch Changes
@@ -48,7 +48,7 @@ if (!module.exports.EventTarget) {
48
48
  }
49
49
  }
50
50
  dispatchEvent(event) {
51
- if (!(event instanceof Event)) {
51
+ if (!(event instanceof module.exports.Event)) {
52
52
  throw new TypeError(
53
53
  `Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`
54
54
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/events",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Cross Platform Smart Event API Ponyfill",
5
5
  "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
6
6
  "repository": {
@@ -0,0 +1,29 @@
1
+ import { EventTarget, Event, CustomEvent } from "@whatwg-node/events";
2
+
3
+ describe("EventTarget", () => {
4
+ it('addEventListener + dispatchEvent', () => {
5
+ const target = new EventTarget();
6
+ const listener = jest.fn();
7
+ target.addEventListener('test', listener);
8
+ target.dispatchEvent(new Event('test'));
9
+ expect(listener).toHaveBeenCalled();
10
+ });
11
+ it('removeEventListener', () => {
12
+ const target = new EventTarget();
13
+ const listener = jest.fn();
14
+ target.addEventListener('test', listener);
15
+ target.removeEventListener('test', listener);
16
+ target.dispatchEvent(new Event('test'));
17
+ expect(listener).not.toHaveBeenCalled();
18
+ });
19
+ });
20
+
21
+ describe('CustomEvent', () => {
22
+ it('detail', () => {
23
+ const target = new EventTarget();
24
+ const listener = jest.fn();
25
+ target.addEventListener('test', listener);
26
+ target.dispatchEvent(new CustomEvent('test', { detail: 123 }));
27
+ expect(listener).toHaveBeenCalledWith(expect.objectContaining({ detail: 123 }));
28
+ });
29
+ })