Solution 0x652a4c8d8d614a77a0eafb2df15ecc122e7733c2d0939ac32325dd8c8b78002d
All checks were successful
elffuss/validation Validation passed
All checks were successful
elffuss/validation Validation passed
T2T-Item: 0x652a4c8d8d614a77a0eafb2df15ecc122e7733c2d0939ac32325dd8c8b78002d T2T-Issue: 0x848d97f788f6a99d51bb5fed8b5045346c66a05c693b03fbe211bd811ee80443
This commit is contained in:
30
tests/acceptance/3/CRITERIA.json
Normal file
30
tests/acceptance/3/CRITERIA.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"schema": "elffuss-t2t/criteria@2",
|
||||
"issue": 3,
|
||||
"criteria": [
|
||||
{
|
||||
"index": 1,
|
||||
"tests": [
|
||||
"tests/acceptance/3/criteria.test.js::criterion 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"index": 2,
|
||||
"tests": [
|
||||
"tests/acceptance/3/criteria.test.js::criterion 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"index": 3,
|
||||
"tests": [
|
||||
"tests/acceptance/3/criteria.test.js::criterion 3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"index": 4,
|
||||
"tests": [
|
||||
"tests/acceptance/3/criteria.test.js::criterion 4"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
58
tests/acceptance/3/criteria.test.js
Normal file
58
tests/acceptance/3/criteria.test.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import * as mod from '../../../web/js/main.js' // the code under test: call it as mod.<name>(...)
|
||||
const source = readFileSync(new URL('../../../web/js/main.js', import.meta.url), 'utf8') // the text of web/js/main.js, for a criterion about how the file is written
|
||||
|
||||
test('criterion 1', () => {
|
||||
// Every `litert:<key>` menu id of web/js/main.js corresponds to a key of `MODELS` exported by `providers/litert.js`.
|
||||
const litertModels = mod.providers.litert.MODELS || {};
|
||||
const menuIds = mod.menuIds || [];
|
||||
const litertMenuIds = menuIds.filter(id => id.startsWith('litert:'));
|
||||
|
||||
for (const litertId of litertMenuIds) {
|
||||
const key = litertId.substring(7);
|
||||
assert.ok(litertModels.hasOwnProperty(key), `Menu ID ${litertId} must correspond to a key in LiteRT MODELS.`);
|
||||
}
|
||||
})
|
||||
|
||||
test('criterion 2', () => {
|
||||
// Every key of `MODELS` that the current menu offers is still offered.
|
||||
const litertModels = mod.providers.litert.MODELS || {};
|
||||
const menuIds = mod.menuIds || [];
|
||||
|
||||
for (const key in litertModels) {
|
||||
const menuId = `litert:${key}`;
|
||||
assert.ok(menuIds.includes(menuId), `LiteRT model key ${key} must have a corresponding menu entry.`);
|
||||
}
|
||||
})
|
||||
|
||||
test('criterion 3', () => {
|
||||
// The label of each LiteRT menu entry equals the `label` of its `MODELS` entry.
|
||||
const litertModels = mod.providers.litert.MODELS || {};
|
||||
const menuIds = mod.menuIds || [];
|
||||
|
||||
for (const key in litertModels) {
|
||||
const menuId = `litert:${key}`;
|
||||
const model = litertModels[key];
|
||||
const menuEntry = menuIds.find(id => id === menuId);
|
||||
|
||||
if (menuEntry) {
|
||||
const menuEntryData = mod.menuData.find(m => m.id === menuId);
|
||||
assert.equal(model.label, menuEntryData.label, `Label mismatch for LiteRT model ${key}.`);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test('criterion 4', () => {
|
||||
// The menu contains no engine entry that the engine registry does not list.
|
||||
const engineRegistry = mod.engineRegistry || {};
|
||||
const menuIds = mod.menuIds || [];
|
||||
|
||||
for (const menuId of menuIds) {
|
||||
if (menuId.startsWith('engine:')) {
|
||||
const engineKey = menuId.substring(7);
|
||||
assert.ok(engineRegistry.hasOwnProperty(engineKey), `Menu entry ${menuId} references an engine not in the registry.`);
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user