Files
digital-me-history/digital-me-backend/test/toubiao.test.js
T
admin 0593ff7e62
nginx serve /uploads direct (audio speed) / patch-nginx (push) Failing after 1m34s
数字我 Digital Me:全量入库(大文件走 Git LFS)
2026-10-10 16:24:43 +08:00

26 lines
874 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { listToubiao, computeDist, QUESTIONS } from '../src/toubiao.js';
test('题库:每题两选项 + 双证揭晓带cite', () => {
const list = listToubiao();
assert.ok(list.length >= 4);
for (const q of list) {
assert.ok(q.qid && q.title && q.situ && q.options?.length === 2);
}
for (const q of Object.values(QUESTIONS)) {
assert.ok(q.real && /《.+》/.test(q.cite), `${q.qid} 揭晓须有正史 cite`);
}
});
test('computeDist:占比正确、零票不除零', () => {
const opts = [{ id: 'a' }, { id: 'b' }];
const r = computeDist({ a: 87, b: 13 }, opts);
assert.equal(r.total, 100);
assert.equal(r.dist.a.pct, 87);
assert.equal(r.dist.b.pct, 13);
const z = computeDist({}, opts);
assert.equal(z.total, 0);
assert.equal(z.dist.a.pct, 0); // 不除零
});