From 8c0aecf0b5d7478d6ed5720b9c6231b9445dd960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20C=C3=B4t=C3=A9?= Date: Sun, 21 Apr 2024 09:51:31 -0400 Subject: [PATCH] Better target listeners --- test/OutputChannel.test.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/OutputChannel.test.js b/test/OutputChannel.test.js index cf643aeb2..6b99494c4 100644 --- a/test/OutputChannel.test.js +++ b/test/OutputChannel.test.js @@ -581,7 +581,6 @@ describe("OutputChannel Object", function() { expect(spy.args[0][1].rawRelease).to.equal(note.rawRelease); }); - it("should return 'OutputChannel' object for method chaining", function () { expect( WEBMIDI_OUTPUT.channels[1].playNote("C3") @@ -604,13 +603,12 @@ describe("OutputChannel Object", function() { // Act WEBMIDI_OUTPUT.channels[channel].playNote(note, {time: timestamp, duration: duration}); - // Assert function assert(deltaTime, message) { if (JSON.stringify(message) == JSON.stringify(expected)) { expect(WebMidi.time - sent - delay - duration).to.be.within(-5, 10); - VIRTUAL_OUTPUT.removeAllListeners(); + VIRTUAL_OUTPUT.removeListener("message", assert); done(); } @@ -633,13 +631,12 @@ describe("OutputChannel Object", function() { // Act WEBMIDI_OUTPUT.channels[channel].playNote(note, {time: timestamp, duration: duration}); - // Assert function assert(deltaTime, message) { if (JSON.stringify(message) == JSON.stringify(expected)) { expect(WebMidi.time - timestamp - duration).to.be.within(-5, 10); - VIRTUAL_OUTPUT.removeAllListeners(); + VIRTUAL_OUTPUT.removeListener("message", assert); done(); } @@ -667,7 +664,7 @@ describe("OutputChannel Object", function() { if (JSON.stringify(message) == JSON.stringify(expected)) { expect(WebMidi.time - sent - duration).to.be.within(-5, 15); - VIRTUAL_OUTPUT.removeAllListeners(); + VIRTUAL_OUTPUT.removeListener("message", assert); done(); } @@ -692,7 +689,7 @@ describe("OutputChannel Object", function() { if (JSON.stringify(message) == JSON.stringify(expected)) { expect(WebMidi.time - sent - note.duration).to.be.within(-5, 10); - VIRTUAL_OUTPUT.removeAllListeners(); + VIRTUAL_OUTPUT.removeListener("message", assert); done(); } @@ -730,7 +727,7 @@ describe("OutputChannel Object", function() { // Assert function assert(deltaTime, message) { expect(message).to.have.ordered.members(expected); - VIRTUAL_OUTPUT.removeAllListeners(); + VIRTUAL_OUTPUT.removeListener("message", assert); done(); }