Files
code/tests/acceptance/7/criteria.test.js
082ae053d1230072f2fc61d3e9aa22ff017b9f30 77104c0df6
All checks were successful
elffuss/validation Validation passed
Solution 0x1e3a862541823407dd86e8209f24811df1793b6f8297cc3df0de9b1595875973
T2T-Item: 0x1e3a862541823407dd86e8209f24811df1793b6f8297cc3df0de9b1595875973
T2T-Issue: 0x7bf84a053d2bd6ce83a7ce9d2799aadf280de622b31dbf03026d0e69d76d3a9a
2026-10-02 08:52:36 +00:00

27 lines
1.3 KiB
JavaScript

import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import * as mod from '../../../web/js/lab.js' // the code under test: call it as mod.<name>(...)
const source = readFileSync(new URL('../../../web/js/lab.js', import.meta.url), 'utf8') // the text of web/js/lab.js, for a criterion about how the file is written
test('criterion 1', () => {
// The label of each `litert:<key>` entry of `BRAINS` equals the `label` of `MODELS[<key>]` from providers/litert.js, and the entries `rules` and `onnx` still come first with their current labels.
const brains = mod.getBrains();
const models = mod.getModels();
const brainsLabels = Object.entries(brains).map(([key, brain]) => brain.label);
const modelsLabels = Object.entries(models).map(([key, model]) => model.label);
for (const [key, brain] of Object.entries(brains)) {
assert.equal(brain.label, models[key].label, `Label mismatch for key: ${key}`);
}
const brainKeys = Object.keys(brains);
const modelKeys = Object.keys(models);
const rulesIndex = brainKeys.indexOf('rules');
const onnxIndex = brainKeys.indexOf('onnx');
assert.equal(rulesIndex, 0, 'rules should be the first entry in BRAINS');
assert.equal(onnxIndex, 1, 'onnx should be the second entry in BRAINS');
})