From d5c8a25a082552e2aefe2654833af9217494b876 Mon Sep 17 00:00:00 2001 From: Jouni Airaksinen Date: Mon, 7 Sep 2020 14:14:53 +0300 Subject: [PATCH] Add test for duplicate events --- Tone/core/util/Emitter.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tone/core/util/Emitter.test.ts b/Tone/core/util/Emitter.test.ts index bca5a785..3f7ffa9a 100644 --- a/Tone/core/util/Emitter.test.ts +++ b/Tone/core/util/Emitter.test.ts @@ -29,6 +29,19 @@ describe("Emitter", () => { emitter.dispose(); }); + it("can unbind duplicate events", () => { + const emitter = new Emitter(); + const callback = () => { + throw new Error("should call this"); + }; + emitter.on("something", callback); + emitter.on("something", callback); + emitter.on("something", callback); + emitter.off("something", callback); + emitter.emit("something"); + emitter.dispose(); + }); + it("'off' does nothing if there is no event scheduled", () => { const emitter = new Emitter(); const callback = () => {