diff --git a/src/__tests__/api/AudioNode.js b/src/__tests__/api/AudioNode.js index 0ddeb18..621c817 100644 --- a/src/__tests__/api/AudioNode.js +++ b/src/__tests__/api/AudioNode.js @@ -126,7 +126,7 @@ describe('api/AudioNode', () => { expect(target._impl.connect.mock.calls[0][1]).toBe(output); }); - it('.disconnect(...args)', () => { + it('.disconnect(...args) mocked', () => { const context = new AudioContext(); const target = context.createGain(); const output = 0; @@ -137,5 +137,21 @@ describe('api/AudioNode', () => { expect(target._impl.disconnect).toHaveBeenCalledTimes(1); expect(target._impl.disconnect.mock.calls[0][0]).toBe(output); }); + + it('.disconnect(...args) real', () => { + const context = new AudioContext(); + const source = context.createGain(); + const dest = context.destination; + + expect(source._impl.outputs[0].inputs).toHaveLength(0); + + source.connect(dest); + + expect(source._impl.outputs[0].inputs).toHaveLength(1); + + source.disconnect(dest); + + expect(source._impl.outputs[0].inputs).toHaveLength(0); + }); }); }); diff --git a/src/impl/core/AudioNodeOutput.js b/src/impl/core/AudioNodeOutput.js index dabd629..0aba4d4 100644 --- a/src/impl/core/AudioNodeOutput.js +++ b/src/impl/core/AudioNodeOutput.js @@ -110,9 +110,11 @@ class AudioNodeOutput { disconnect(...args) { const isTargetToDisconnect = args.length === 1 - ? (target) => target.node === args[0] + ? (target) => target.node === args[0] || target.node === args[0]._impl : args.length === 2 - ? (target) => target.node === args[0] && target.index === args[1] + ? (target) => + (target.node === args[0] || target.node === args[0]._impl) && + target.index === args[1] : () => true; for (let i = this.inputs.length - 1; i >= 0; i--) {