Files
order_system/tests/test_money_js.cjs
T

8 lines
478 B
JavaScript

const assert = require('node:assert/strict');
const money = require('../po_app/static/money.js');
assert.equal(money.format(money.lineCents('1','0.334') + money.lineCents('1','0.334')), '0.66');
assert.equal(money.format(money.lineCents('1','2.675')), '2.68');
assert.equal(money.format(money.lineCents('3','0.3333')), '1.00');
for (const bad of ['-1','NaN','Infinity','abc','0.00001']) assert.throws(()=>money.lineCents(bad,'1'));
console.log('Decimal preview checks passed');