Tone.js/test/helper/Test.js

55 lines
1.1 KiB
JavaScript
Raw Normal View History

/* global mocha*/
2015-08-16 18:58:25 +00:00
define(["Tone/core/Tone", "deps/chai"], function (Tone, chai) {
2015-08-16 18:58:25 +00:00
//add a chai test
chai.Assertion.addMethod("percentageFrom", function(val, percent){
new chai.Assertion(this._obj).to.be.closeTo(val, val * percent);
});
2015-08-16 18:58:25 +00:00
//testing setup
window.expect = chai.expect;
2016-05-14 23:22:25 +00:00
mocha.setup({
ui: "bdd",
// make this very long cause sometimes the travis CI server is slow
timeout : 5000
2016-05-14 23:22:25 +00:00
});
2015-08-16 18:58:25 +00:00
2015-08-16 18:58:25 +00:00
/**
* The Test object
*/
var Test = {
input : Tone.context.createGain()
};
Test.run = function(){
mocha.run();
};
Test.wasDisposed = function(obj){
for (var prop in obj){
var member = obj[prop];
if (typeof member !== "function" &&
typeof member !== "string" &&
typeof member !== "number" &&
typeof member !== "boolean" &&
2015-08-17 02:22:38 +00:00
typeof member !== "undefined" &&
2015-08-16 18:58:25 +00:00
prop !== "preset" &&
!(member instanceof AudioContext) &&
!obj.constructor.prototype[prop]){
2015-08-16 18:58:25 +00:00
if (member !== null){
throw Error("property was not completely disposed: "+prop);
}
}
}
};
Test.connect = function(node, inputNumber){
this.input.connect(node, 0, inputNumber);
this.input.disconnect();
};
return Test;
});