Add node tests
This commit is contained in:
36
test/node/expect.js
Normal file
36
test/node/expect.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import expect from 'expect.js';
|
||||
|
||||
/**
|
||||
* Assert value is within some tolerance of a number.
|
||||
* @param {number} n Number.
|
||||
* @param {number} tol Tolerance.
|
||||
* @return {expect.Assertion} The assertion.
|
||||
*/
|
||||
expect.Assertion.prototype.roughlyEqual = function (n, tol) {
|
||||
this.assert(
|
||||
Math.abs(this.obj - n) <= tol,
|
||||
function () {
|
||||
return (
|
||||
'expected ' +
|
||||
expect.stringify(this.obj) +
|
||||
' to be within ' +
|
||||
tol +
|
||||
' of ' +
|
||||
n
|
||||
);
|
||||
},
|
||||
function () {
|
||||
return (
|
||||
'expected ' +
|
||||
expect.stringify(this.obj) +
|
||||
' not to be within ' +
|
||||
tol +
|
||||
' of ' +
|
||||
n
|
||||
);
|
||||
}
|
||||
);
|
||||
return this;
|
||||
};
|
||||
|
||||
export default expect;
|
||||
Reference in New Issue
Block a user