Tone.js/Tone/component/channel/PanVol.test.ts
Yotam Mann aaf880c925
Using web-test-runner for tests, updating import paths (#1242)
* WIP moving tests to web-test-runner

* updating thresholds

* Adding file extensions

* Testing integrations

* linting

* fixing dep

* moving back to root dir

* prettier all of the files

* updating eslint rules to use with prettier

* remove import package

* moving tsignore around

* removing unneeded ignores

* all tests run on puppeteer, no need for testing guards

* linting

* import type syntax

* cleaning up

* Update package.json
2024-05-03 14:31:14 -04:00

55 lines
1.5 KiB
TypeScript

import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { Offline } from "../../../test/helper/Offline.js";
import { PassAudio } from "../../../test/helper/PassAudio.js";
import { Signal } from "../../signal/Signal.js";
import { PanVol } from "./PanVol.js";
describe("PanVol", () => {
BasicTests(PanVol);
context("Pan and Volume", () => {
it("can be constructed with the panning and volume value", () => {
const panVol = new PanVol(0.3, -12);
expect(panVol.pan.value).to.be.closeTo(0.3, 0.001);
expect(panVol.volume.value).to.be.closeTo(-12, 0.1);
panVol.dispose();
});
it("can be constructed with an options object", () => {
const panVol = new PanVol({
mute: true,
pan: 0.2,
});
expect(panVol.pan.value).to.be.closeTo(0.2, 0.001);
expect(panVol.mute).to.be.true;
panVol.dispose();
});
it("can set/get with an object", () => {
const panVol = new PanVol();
panVol.set({
volume: -10,
});
expect(panVol.get().volume).to.be.closeTo(-10, 0.1);
panVol.dispose();
});
it("passes the incoming signal through", () => {
return PassAudio((input) => {
const panVol = new PanVol().toDestination();
input.connect(panVol);
});
});
it("can mute the volume", () => {
return Offline(() => {
const vol = new PanVol(0).toDestination();
new Signal(1).connect(vol);
vol.mute = true;
}).then((buffer) => {
expect(buffer.isSilent()).to.be.true;
});
});
});
});