Skip to content

Commit

Permalink
Better target listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Philippe Côté committed Apr 21, 2024
1 parent d409c09 commit 8c0aecf
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/OutputChannel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 8c0aecf

Please sign in to comment.