open-standards/wai/quantum-studio/test/verify-text.test.mjs
Transaction Science 8436745b66 wai-quantum: the second review's seven, and a set's receipt in section 8
RFC 8785's spelling of a large whole double is taken; a set's receipt is section
8.6, with three reasons, and every surface judges a set by it; a receipt is
checked on its text in the Studio, the desktop app and the npm example; set
requests are screened; the tools take a job's text; qubit_names covers every
qubit qasm3 acts on; the service's verify schema describes signer. Corpus:
two sets made by the command line, fourteen set vectors, five number vectors,
one names vector; three more plants. Work in progress: its battery is running.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 07:23:03 -05:00

22 lines
1.2 KiB
JavaScript

// A receipt is checked on its text: what the person or the engine gave, never a
// JavaScript object written out again, which moves a member named by digits
// ahead of the others and rewrites a large whole number.
//
// node test/verify-text.test.mjs
let fails = 0;
const check = (ok, what) => { console.log(`${ok ? 'PASS' : 'FAIL'} ${what}`); if (!ok) fails += 1; };
const calls = [];
globalThis.window = { __TAURI__: { core: { invoke: async (cmd, args) => { calls.push([cmd, args]); return JSON.stringify({ valid: true }); } } } };
const { DesktopEngine } = await import('../src/engine.js');
const desk = new DesktopEngine();
const text = '{"request":{"x":1},"result":{"counts":{"00":1,"11":2},"receipt":{}}}';
await desk.verify(text);
check(calls.at(-1)?.[1]?.job === text, 'the desktop app is given the receipt\'s text as it is');
await desk.verify(JSON.parse(text));
check(typeof calls.at(-1)?.[1]?.job === 'string', 'an object, all there is, is written out');
const { jobText } = await import('../src/job-text.js');
check(jobText(text) === text && jobText({ a: 1 }) === '{"a":1}', 'the worker sends a text as it is, an object written out');
if (fails) { console.log(`${fails} check(s) failed`); process.exit(1); }
console.log('verify-text: every check held');