VEHwang's picture
Upload CoCogni4D-Bench (questions, media, scripts, render records, code) (part 6)
5afd2f7 verified
Raw History Blame Contribute Delete
1.34 kB
import assert from 'node:assert/strict';
import test from 'node:test';
import {lengthLabel, localTime, runSummary} from '../src/generation-logic.ts';
const stages = [{seconds: 10.4}, {seconds: 5.2}] as Parameters<typeof runSummary>[0]['stages'];
test('结果屏顶部写出完成与否、开始时间和用时、和哪一批比(设计 R-1)', () => {
const done = runSummary({status: 'completed', created_at: '2026-10-23T11:25:31+08:00', stages}, {label: '上次', created_at: '2026-10-23T10:00:00+08:00'});
assert.equal(done.state, '完成'); assert.ok(done.ok);
assert.match(done.time, /开始 · 用时 16 s$/);
assert.match(done.compare, /^和上一批比:上次(/);
const partial = runSummary({status: 'completed_with_failures', created_at: '2026-10-23T11:25:31+08:00', stages});
assert.equal(partial.state, '完成(有失败段)'); assert.ok(!partial.ok);
assert.equal(partial.compare, '没有更早的批次,不比');
});
test('时刻用中文格式、不随浏览器语言;段长档位写中文', () => {
assert.match(localTime('2026-10-23T12:46:01+08:00'), /^2026\/10\/23 \d{2}:46:01$/);
assert.doesNotMatch(localTime('2026-10-23T12:46:01+08:00'), /AM|PM/);
assert.equal(lengthLabel('short'), '短段'); assert.equal(lengthLabel('long'), '长段'); assert.equal(lengthLabel('x'), 'x');
});