diff --git a/Tone/component/analysis/Analyser.test.ts b/Tone/component/analysis/Analyser.test.ts index aaa385d5..ba9de0e2 100644 --- a/Tone/component/analysis/Analyser.test.ts +++ b/Tone/component/analysis/Analyser.test.ts @@ -1,6 +1,5 @@ import { expect } from "chai"; import { BasicTests } from "test/helper/Basic"; -import { connectFrom } from "test/helper/Connect"; import { Noise } from "../../source/Noise"; import { Analyser } from "./Analyser"; @@ -8,12 +7,6 @@ describe("Analyser", () => { BasicTests(Analyser); - it("handles input connection", () => { - const anl = new Analyser(); - connectFrom().connect(anl); - anl.dispose(); - }); - it("can get and set properties", () => { const anl = new Analyser(); anl.set({ diff --git a/Tone/component/envelope/AmplitudeEnvelope.test.ts b/Tone/component/envelope/AmplitudeEnvelope.test.ts index 2cdbaf73..f0764e13 100644 --- a/Tone/component/envelope/AmplitudeEnvelope.test.ts +++ b/Tone/component/envelope/AmplitudeEnvelope.test.ts @@ -64,13 +64,6 @@ describe("AmplitudeEnvelope", () => { context("Envelope", () => { - it("handles input and output connections", () => { - const ampEnv = new AmplitudeEnvelope(); - connectFrom().connect(ampEnv); - ampEnv.connect(connectTo()); - ampEnv.dispose(); - }); - it("extends envelope", () => { const ampEnv = new AmplitudeEnvelope(); expect(ampEnv).to.be.instanceOf(Envelope); diff --git a/Tone/component/filter/EQ3.test.ts b/Tone/component/filter/EQ3.test.ts index fcc45502..3698d916 100644 --- a/Tone/component/filter/EQ3.test.ts +++ b/Tone/component/filter/EQ3.test.ts @@ -10,12 +10,6 @@ describe("EQ3", () => { context("EQing", () => { - it("handles input and output connections", () => { - const eq3 = new EQ3(); - connectFrom().connect(eq3); - eq3.dispose(); - }); - it("can be constructed with an object", () => { const eq3 = new EQ3({ high : -10, diff --git a/Tone/component/filter/Filter.test.ts b/Tone/component/filter/Filter.test.ts index 709c443c..fa8773f9 100644 --- a/Tone/component/filter/Filter.test.ts +++ b/Tone/component/filter/Filter.test.ts @@ -12,12 +12,6 @@ describe("Filter", () => { context("Filtering", () => { - it("handles input and output connections", () => { - const filter = new Filter(); - connectFrom().connect(filter); - filter.dispose(); - }); - it("can be constructed with a arguments", () => { const filter = new Filter(200, "highpass"); expect(filter.frequency.value).to.be.closeTo(200, 0.001); diff --git a/Tone/signal/Abs.test.ts b/Tone/signal/Abs.test.ts index 5bf85636..8499c10a 100644 --- a/Tone/signal/Abs.test.ts +++ b/Tone/signal/Abs.test.ts @@ -10,13 +10,6 @@ describe("Abs", () => { context("Absolute Value", () => { - it("handles input and output connections", () => { - const abs = new Abs(); - connectFrom().connect(abs); - abs.connect(connectTo()); - abs.dispose(); - }); - it("outputs the same value for positive values", () => { return ConstantOutput(() => { const signal = new Signal(0.4); diff --git a/Tone/signal/AudioToGain.test.ts b/Tone/signal/AudioToGain.test.ts index eb15f81d..3c641e02 100644 --- a/Tone/signal/AudioToGain.test.ts +++ b/Tone/signal/AudioToGain.test.ts @@ -12,13 +12,6 @@ describe("AudioToGain", () => { BasicTests(AudioToGain); - it("handles input and output connections", () => { - const a2g = new AudioToGain(); - a2g.connect(connectTo()); - connectFrom().connect(a2g); - a2g.dispose(); - }); - it("normalizes an oscillator to 0,1", () => { return Offline(() => { const osc = new Oscillator(1000).start(); diff --git a/Tone/signal/GainToAudio.test.ts b/Tone/signal/GainToAudio.test.ts index 242705cc..ad6eea30 100644 --- a/Tone/signal/GainToAudio.test.ts +++ b/Tone/signal/GainToAudio.test.ts @@ -11,13 +11,6 @@ describe("GainToAudio", () => { context("Gain To Audio", () => { - it("handles input and output connections", () => { - const g2a = new GainToAudio(); - connectFrom().connect(g2a); - g2a.connect(connectTo()); - g2a.dispose(); - }); - it("outputs 0 for an input value of 0.5", () => { return ConstantOutput(() => { const sig = new Signal(0.5); diff --git a/Tone/signal/Negate.test.ts b/Tone/signal/Negate.test.ts index e819cb35..eaf24aa6 100644 --- a/Tone/signal/Negate.test.ts +++ b/Tone/signal/Negate.test.ts @@ -10,13 +10,6 @@ describe("Negate", () => { context("Negating", () => { - it("handles input and output connections", () => { - const negate = new Negate(); - connectFrom().connect(negate); - negate.connect(connectTo()); - negate.dispose(); - }); - it("negateates a positive value", () => { return ConstantOutput(() => { const signal = new Signal(1); diff --git a/Tone/signal/Signal.test.ts b/Tone/signal/Signal.test.ts index a4ac09c7..c7f903b2 100644 --- a/Tone/signal/Signal.test.ts +++ b/Tone/signal/Signal.test.ts @@ -13,10 +13,10 @@ describe("Signal", () => { context("Signal Rate Value", () => { - it("handles input and output connections", () => { + it("has 1 input and 1 output", () => { const signal = new Signal(); - connectFrom().connect(signal); - signal.connect(connectTo()); + expect(signal.numberOfInputs).to.equal(1); + expect(signal.numberOfOutputs).to.equal(1); signal.dispose(); }); diff --git a/Tone/signal/Zero.test.ts b/Tone/signal/Zero.test.ts index d98d0b21..8c2d6b67 100644 --- a/Tone/signal/Zero.test.ts +++ b/Tone/signal/Zero.test.ts @@ -1,5 +1,5 @@ +import { expect } from "chai"; import { BasicTests } from "test/helper/Basic"; -import { connectTo } from "test/helper/Connect"; import { ConstantOutput } from "test/helper/ConstantOutput"; import { Zero } from "./Zero"; @@ -9,10 +9,11 @@ describe("Zero", () => { context("Zero", () => { - it("handles output connections", () => { - const abs = new Zero(); - abs.connect(connectTo()); - abs.dispose(); + it("has 0 inputs and 1 output", () => { + const zero = new Zero(); + expect(zero.numberOfInputs).to.equal(0); + expect(zero.numberOfOutputs).to.equal(1); + zero.dispose(); }); it("always outputs 0", () => { diff --git a/test/helper/Basic.ts b/test/helper/Basic.ts index 8c175bd2..4379d097 100644 --- a/test/helper/Basic.ts +++ b/test/helper/Basic.ts @@ -4,6 +4,7 @@ import "Tone/core/context/Destination"; import { OfflineContext } from "Tone/core/context/OfflineContext"; import { ToneWithContext } from "Tone/core/context/ToneWithContext"; import { Tone } from "Tone/core/Tone"; +import { ConnectTest } from "./Connect"; export const testAudioContext = new OfflineContext(1, 1, 11025); testAudioContext.initialize(); @@ -47,5 +48,7 @@ export function BasicTests(Constr, ...args: any[]): void { } instance.dispose(); }); + + ConnectTest(Constr, ...args); }); } diff --git a/test/helper/Connect.ts b/test/helper/Connect.ts index 1c521062..7452f6b2 100644 --- a/test/helper/Connect.ts +++ b/test/helper/Connect.ts @@ -1,4 +1,5 @@ import { Gain } from "Tone/core/context/Gain"; +import { ToneAudioNode } from "Tone/core/context/ToneAudioNode"; export function connectFrom(): Gain { return new Gain(); @@ -7,3 +8,22 @@ export function connectFrom(): Gain { export function connectTo(): Gain { return new Gain(); } + +export function ConnectTest(constr, ...args: any[]): void { + + it("handles input and output connections", () => { + const instance = new constr(...args); + // test each of the input and outputs and connect + if (instance.numberOfInputs) { + for (let input = 0; input < instance.numberOfInputs; input++) { + connectFrom().connect(instance, 0, input); + } + } + if (instance.numberOfOutputs) { + for (let output = 0; output < instance.numberOfOutputs; output++) { + instance.connect(connectTo(), output, 0); + } + } + instance.dispose(); + }); +}