← Source tree
web_demo/test_inference.cjs
"use strict";
const test = require("node:test"), assert = require("node:assert/strict");
const fs = require("node:fs");
const { score } = require("./inference.js");
require("./model.js");
const model = globalThis.REVIEWQUEUE_MODEL;
test("204 exported-forest scores match scikit-learn within 1e-8", () => {
const probes = JSON.parse(fs.readFileSync(__dirname + "/../browser_parity.json", "utf8"));
assert.equal(probes.length, 204);
for (const row of probes) {
const actual = score(model, row.amount, row.quantity).decision_score;
assert.ok(Math.abs(actual - row.expected) < 1e-8, JSON.stringify({row, actual}));
}
});
test("live normal and extreme examples produce distinct review decisions", () => {
assert.equal(score(model, "119.00", "1").needs_review, false);
assert.equal(score(model, "99000.00", "20").needs_review, true);
});
test("ambiguous, zero and overflowing browser inputs fail explicitly", () => {
for (const [amount, quantity] of [["1,234", "1"], ["120", "0"], ["1e300", "1"], ["true", "1"], ["1", "-1"]])
assert.throws(() => score(model, amount, quantity));
});