Tone.js/test/signal/GreaterThanZero.js
2015-08-24 17:29:19 -04:00

91 lines
No EOL
2.1 KiB
JavaScript

define(["helper/Offline", "helper/Basic", "Tone/signal/GreaterThanZero", "Tone/signal/Signal"],
function (Offline, Basic, GreaterThanZero, Signal) {
describe("GreaterThanZero", function(){
Basic(GreaterThanZero);
describe("Comparison", function(){
it("Outputs 0 when the value is less than 0", function(done){
var signal, gtz;
var offline = new Offline();
offline.before(function(dest){
signal = new Signal(-1);
gtz = new GreaterThanZero();
signal.connect(gtz);
gtz.connect(dest);
});
offline.test(function(sample){
expect(sample).to.equal(0);
});
offline.after(function(){
signal.dispose();
gtz.dispose();
done();
});
offline.run();
});
it("Outputs 1 when the value is greater than 0", function(done){
var signal, gtz;
var offline = new Offline();
offline.before(function(dest){
signal = new Signal(1);
gtz = new GreaterThanZero();
signal.connect(gtz);
gtz.connect(dest);
});
offline.test(function(sample){
expect(sample).to.equal(1);
});
offline.after(function(){
signal.dispose();
gtz.dispose();
done();
});
offline.run();
});
it("Outputs 0 when the value is equal to 0", function(done){
var signal, gtz;
var offline = new Offline();
offline.before(function(dest){
signal = new Signal(0);
gtz = new GreaterThanZero();
signal.connect(gtz);
gtz.connect(dest);
});
offline.test(function(sample){
expect(sample).to.equal(0);
});
offline.after(function(){
signal.dispose();
gtz.dispose();
done();
});
offline.run();
});
it("Outputs 1 when the value is slightly above 0", function(done){
var signal, gtz;
var offline = new Offline();
offline.before(function(dest){
signal = new Signal(0.001);
gtz = new GreaterThanZero();
signal.connect(gtz);
gtz.connect(dest);
});
offline.test(function(sample){
expect(sample).to.equal(1);
});
offline.after(function(){
signal.dispose();
gtz.dispose();
done();
});
offline.run();
});
});
});
});