UNPKG

@tdb/util

Version:
30 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var chai_1 = require("chai"); var _1 = require("."); describe('round', function () { it('rounds to 0 decimal places', function () { chai_1.expect(_1.value.round(1.123)).to.equal(1); chai_1.expect(_1.value.round(1.513)).to.equal(2); }); it('rounds to 1 decimal place', function () { chai_1.expect(_1.value.round(1.123, 1)).to.equal(1.1); chai_1.expect(_1.value.round(1.153, 1)).to.equal(1.2); }); it('rounds to 2 decimal places', function () { chai_1.expect(_1.value.round(1.123, 2)).to.equal(1.12); chai_1.expect(_1.value.round(1.156, 2)).to.equal(1.16); }); it('rounds to 3 decimal places', function () { chai_1.expect(_1.value.round(1.123, 3)).to.equal(1.123); chai_1.expect(_1.value.round(1.156, 3)).to.equal(1.156); }); }); describe('random', function () { it('is random within bounds (5..10)', function () { var res = _1.value.random(5, 10); chai_1.expect(res).to.greaterThan(4); chai_1.expect(res).to.lessThan(11); }); }); //# sourceMappingURL=value.math.test.js.map