chainy/node_modules/deck/test/normalize.js

21 lines
490 B
JavaScript
Raw Permalink Normal View History

2020-01-26 19:03:32 +00:00
var deck = require('deck');
var assert = require('assert');
var eql = assert.deepEqual;
exports.normalize = function () {
eql(
deck.normalize({ a : 1, b : 3, c : 4 }),
{ a : 0.125, b : 0.375, c : 0.5 }
);
var t = 0.1 + 0.2 + 0.05;
eql(
deck.normalize({ a : 0.1, b : 0.2, c : 0.05 }),
{ a : 0.1 / t, b : 0.2 / t, c : 0.05 / t }
);
assert.throws(function () {
deck.normalize({ a : 0.1, b : 0.2, c : [] });
});
};