Tone.js/test/source/PWMOscillator.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

import BasicTests from "helper/Basic";
import PWMOscillator from "Tone/source/PWMOscillator";
import Offline from "helper/Offline";
import SourceTests from "helper/SourceTests";
import OscillatorTests from "helper/OscillatorTests";
import Test from "helper/Test";
import CompareToFile from "helper/CompareToFile";
describe("PWMOscillator", function(){
//run the common tests
BasicTests(PWMOscillator);
SourceTests(PWMOscillator);
OscillatorTests(PWMOscillator);
it("matches a file", function(){
return CompareToFile(function(){
var osc = new PWMOscillator().toMaster();
osc.start(0.1);
}, "pwmOscillator.wav");
});
2015-08-21 21:03:48 +00:00
context("Modulation Frequency", function(){
2015-08-21 21:03:48 +00:00
it("can set the modulation frequency", function(){
var pwm = new PWMOscillator();
pwm.modulationFrequency.value = 0.2;
expect(pwm.modulationFrequency.value).to.be.closeTo(0.2, 0.001);
pwm.dispose();
2015-08-21 21:03:48 +00:00
});
it("can connect a signal to the modulationFrequency", function(){
var pwm = new PWMOscillator();
Test.connect(pwm.modulationFrequency);
pwm.dispose();
});
2015-08-21 21:03:48 +00:00
});
context("Types", function(){
it("reports it's type", function(){
var osc = new PWMOscillator();
expect(osc.type).to.equal("pwm");
expect(osc.baseType).to.equal("pwm");
2019-02-01 16:49:47 +00:00
expect(osc.partials).to.deep.equal([]);
osc.dispose();
});
});
});