diff options
| author | 2023-01-14 16:36:59 -0800 | |
|---|---|---|
| committer | 2023-01-14 16:37:16 -0800 | |
| commit | d01ec47529fb7d035b9d369c1e524abf220c8242 (patch) | |
| tree | bcd87e295ae87e32efcc2615f324c0e5abe660f0 /test/bun.js | |
| parent | 7fa023b8b55e7726eba90f462661c1e2c4641951 (diff) | |
| download | bun-d01ec47529fb7d035b9d369c1e524abf220c8242.tar.gz bun-d01ec47529fb7d035b9d369c1e524abf220c8242.tar.zst bun-d01ec47529fb7d035b9d369c1e524abf220c8242.zip | |
Fixes #1794
Diffstat (limited to '')
| -rw-r--r-- | test/bun.js/event-emitter.test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/bun.js/event-emitter.test.ts b/test/bun.js/event-emitter.test.ts index 701b28df3..c9bef0ff4 100644 --- a/test/bun.js/event-emitter.test.ts +++ b/test/bun.js/event-emitter.test.ts @@ -22,6 +22,24 @@ describe("EventEmitter", () => { expect(emitter.getMaxListeners()).toBe(100); }); + test("EventEmitter.removeAllListeners()", () => { + var emitter = new EventEmitter(); + var ran = false; + emitter.on("hey", () => { + ran = true; + }); + emitter.removeAllListeners(); + expect(emitter.listenerCount("hey")).toBe(0); + emitter.emit("hey"); + expect(ran).toBe(false); + emitter.on("hey", () => { + ran = true; + }); + emitter.emit("hey"); + expect(ran).toBe(true); + expect(emitter.listenerCount("hey")).toBe(1); + }); + // These are also tests for the done() function in the test runner. test("EventEmitter emit (different tick)", (done) => { var emitter = new EventEmitter(); |
