test: 修正 mock 的滥用情况

This commit is contained in:
claude-code-best
2026-04-17 10:13:09 +08:00
parent c5ab83a3fc
commit a14b7f352b
15 changed files with 10 additions and 843 deletions

View File

@@ -1,27 +1,4 @@
import { mock, describe, expect, test } from "bun:test";
// Mock ink/stringWidth to avoid heavy Ink import chain
mock.module("src/ink/stringWidth.js", () => ({
stringWidth: (str: string) => {
// Simplified width calculation for test purposes
let width = 0;
for (const char of str) {
const code = char.codePointAt(0)!;
// CJK Unified Ideographs and common full-width ranges
if (
(code >= 0x4e00 && code <= 0x9fff) || // CJK
(code >= 0x3000 && code <= 0x303f) || // CJK Symbols
(code >= 0xff01 && code <= 0xff60) || // Fullwidth Forms
(code >= 0xf900 && code <= 0xfaff) // CJK Compatibility
) {
width += 2;
} else if (code > 0) {
width += 1;
}
}
return width;
},
}));
import { describe, expect, test } from "bun:test";
const sliceAnsi = (await import("../sliceAnsi")).default;