Tone.js/Tone/source/oscillator/PWMOscillator.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

50 lines
1.4 KiB
TypeScript

import { expect } from "chai";
import { BasicTests } from "../../../test/helper/Basic.js";
import { CompareToFile } from "../../../test/helper/CompareToFile.js";
import { connectFrom } from "../../../test/helper/Connect.js";
import { OscillatorTests } from "../../../test/helper/OscillatorTests.js";
import { SourceTests } from "../../../test/helper/SourceTests.js";
import { PWMOscillator } from "./PWMOscillator.js";
describe("PWMOscillator", () => {
// run the common tests
BasicTests(PWMOscillator);
SourceTests(PWMOscillator);
OscillatorTests(PWMOscillator);
it("matches a file", () => {
return CompareToFile(
() => {
const osc = new PWMOscillator().toDestination();
osc.start(0.1);
},
"pwmOscillator.wav",
0.01
);
});
context("Modulation Frequency", () => {
it("can set the modulation frequency", () => {
const pwm = new PWMOscillator();
pwm.modulationFrequency.value = 0.2;
expect(pwm.modulationFrequency.value).to.be.closeTo(0.2, 0.001);
pwm.dispose();
});
it("can connect a signal to the modulationFrequency", () => {
const pwm = new PWMOscillator();
connectFrom().connect(pwm.modulationFrequency);
pwm.dispose();
});
});
context("Types", () => {
it("reports it's type", () => {
const osc = new PWMOscillator();
expect(osc.type).to.equal("pwm");
expect(osc.baseType).to.equal("pwm");
expect(osc.partials).to.deep.equal([]);
osc.dispose();
});
});
});