Add node tests

This commit is contained in:
Tim Schaub
2021-04-28 15:00:04 -07:00
parent c301d2413b
commit 7b934a06be
61 changed files with 1216 additions and 449 deletions

36
test/node/expect.js Normal file
View 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;