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.(...) 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:` entry of `BRAINS` equals the `label` of `MODELS[]` 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'); })