Files
2026Technology-Competition/frontend/tests/ws.test.ts
T

19 lines
759 B
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { applyProgressEvent } from '../src/ws.ts';
test('applyProgressEvent 渲染 progress 角色', () => {
const got: Array<[string, string]> = [];
applyProgressEvent({ type: 'progress', step: 'parse', detail: '完成' }, (role, text) => got.push([role, text]));
assert.strictEqual(got.length, 1);
assert.strictEqual(got[0][0], 'progress');
assert.ok(got[0][1].includes('parse'));
});
test('applyProgressEvent 渲染 error 角色', () => {
const got: Array<[string, string]> = [];
applyProgressEvent({ type: 'error', detail: '炸了' }, (role, text) => got.push([role, text]));
assert.strictEqual(got[0][0], 'error');
assert.ok(got[0][1].includes('炸了'));
});