test(ai-review): 補日誌 input/output/result helper 與誤報裁決、usage 解析、parseBot 健壯性測試

This commit is contained in:
Jeffery
2026-06-23 15:15:24 +08:00
parent 374bb4ec75
commit 756b2cd4ef
4 changed files with 51 additions and 1 deletions
+20 -1
View File
@@ -1,6 +1,6 @@
import { describe, it, afterEach, mock } from 'node:test';
import assert from 'node:assert/strict';
import { section, step, line, ok, warn, error } from './log.js';
import { section, step, line, input, output, result, ok, warn, error } from './log.js';
afterEach(() => mock.restoreAll());
@@ -35,6 +35,25 @@ describe('log helpers', () => {
]);
});
it('formats input/output and pass/fail result messages', () => {
const calls = [];
mock.method(console, 'log', (...args) => {
calls.push(args.join(' '));
});
input('5 筆');
output('3 筆');
result(true, '通過');
result(false, '未通過');
assert.deepEqual(calls, [
' ← 輸入:5 筆',
' → 輸出:3 筆',
' ✅ 成功:通過',
' ❌ 失敗:未通過',
]);
});
it('formats warn messages with console.warn', () => {
const calls = [];
mock.method(console, 'warn', (...args) => {