From e2da92fae71435c2994ebe25d704c4c304356112 Mon Sep 17 00:00:00 2001 From: Corey Frang Date: Thu, 21 Jun 2018 11:25:27 -0400 Subject: [PATCH] cleanup tests a bit --- src/GreenPlayer.js | 6 +++--- test/SoundPlayer.js | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/GreenPlayer.js b/src/GreenPlayer.js index 24d281f..882b067 100644 --- a/src/GreenPlayer.js +++ b/src/GreenPlayer.js @@ -116,11 +116,11 @@ class SoundPlayer extends EventEmitter { return; } - if (this.volumeEffect !== null) { - this.volumeEffect.connect(target); - } else { + if (this.volumeEffect === null) { this.outputNode.disconnect(); this.outputNode.connect(target.getInputNode()); + } else { + this.volumeEffect.connect(target); } return this; diff --git a/test/SoundPlayer.js b/test/SoundPlayer.js index c55fe6f..51b2efe 100644 --- a/test/SoundPlayer.js +++ b/test/SoundPlayer.js @@ -39,14 +39,13 @@ tap.test('SoundPlayer', suite => { suite.plan(4); - suite.test('play initializes and creates chain', t => { + suite.test('play initializes and creates source node', t => { t.plan(3); t.equal(soundPlayer.initialized, false, 'not yet initialized'); soundPlayer.play(); t.equal(soundPlayer.initialized, true, 'now is initialized'); - let buffer = audioContext.DECODE_AUDIO_DATA_RESULT.toJSON(); t.deepEqual(soundPlayer.outputNode.toJSON(), { - buffer, + buffer: audioContext.DECODE_AUDIO_DATA_RESULT.toJSON(), inputs: [], loop: false, loopEnd: 0, @@ -65,7 +64,7 @@ tap.test('SoundPlayer', suite => { t.plan(1); soundPlayer.play(); soundPlayer.connect(audioEngine); - t.deepEqual(audioEngine.inputNode.toJSON().inputs, [ + t.deepEqual(help.engineInputs, [ soundPlayer.outputNode.toJSON() ], 'output node connects to input node'); t.end(); @@ -80,7 +79,7 @@ tap.test('SoundPlayer', suite => { audioContext.$processTo(0); soundPlayer.stop(); t.equal(soundPlayer.outputNode, null, 'nullify outputNode immediately (taken sound is stopping)'); - t.deepEqual(audioEngine.inputNode.toJSON().inputs, [{ + t.deepEqual(help.engineInputs, [{ name: 'GainNode', gain: { value: 1, @@ -90,13 +89,13 @@ tap.test('SoundPlayer', suite => { }], 'output node connects to gain node to input node'); audioContext.$processTo(audioEngine.DECAY_TIME / 2); - const engineInputs = audioEngine.inputNode.toJSON().inputs; + const engineInputs = help.engineInputs; t.notEqual(engineInputs[0].gain.value, 1, 'gain value should not be 1'); t.notEqual(engineInputs[0].gain.value, 0, 'gain value should not be 0'); t.equal(outputNode.$state, 'PLAYING'); audioContext.$processTo(audioEngine.DECAY_TIME); - t.deepEqual(audioEngine.inputNode.toJSON().inputs, [{ + t.deepEqual(help.engineInputs, [{ name: 'GainNode', gain: { value: 0,