@0xcert/utils
Version:
General utility module with common helper functions.
21 lines • 779 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");
const spec = new spec_1.Spec();
spec.test('converts floats to integers', (ctx) => {
ctx.is(__1.toInteger(9000), 9000);
ctx.is(__1.toInteger(9000.1982), 9000);
ctx.is(__1.toInteger(0.1982), 0);
ctx.is(__1.toInteger('10000.124'), 10000);
});
spec.test('handles non-numeric and other invalid values', (ctx) => {
ctx.is(__1.toInteger('foo'), 0);
ctx.is(__1.toInteger(null), 0);
ctx.is(__1.toInteger(true), 1);
ctx.is(__1.toInteger(false), 0);
ctx.is(__1.toInteger(undefined), 0);
ctx.is(__1.toInteger(Math.pow(2, 100)), 0);
});
exports.default = spec;
//# sourceMappingURL=to-integer.test.js.map
;