ESLint 升级到 recommended-type-checked + stylistic-type-checked, 引入 perfectionist 导入排序和 import 插件导入验证。 Prettier 显式声明全部格式化参数,消除跨环境差异。 TypeScript 启用 noUnusedLocals 和 noPropertyAccessFromIndexSignature。 完善 ignore 列表,排除 .agents/、bun.lock、data/ 等。 引入 husky + lint-staged(pre-commit)+ commitlint(commit-msg)。 更新 DEVELOPMENT.md 代码质量章节。 修复所有新增规则检测到的类型和风格违规。
31 lines
911 B
TypeScript
31 lines
911 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
|
|
import { checkDuration } from "../../../../../src/server/checker/runner/shared/duration";
|
|
|
|
describe("checkDuration", () => {
|
|
test("未配置 maxDurationMs 返回匹配成功", () => {
|
|
const r = checkDuration(100);
|
|
expect(r.matched).toBe(true);
|
|
expect(r.failure).toBeNull();
|
|
});
|
|
|
|
test("duration 在限制内匹配成功", () => {
|
|
const r = checkDuration(50, 100);
|
|
expect(r.matched).toBe(true);
|
|
expect(r.failure).toBeNull();
|
|
});
|
|
|
|
test("duration 等于限制匹配成功", () => {
|
|
const r = checkDuration(100, 100);
|
|
expect(r.matched).toBe(true);
|
|
});
|
|
|
|
test("duration 超过限制匹配失败", () => {
|
|
const r = checkDuration(200, 100);
|
|
expect(r.matched).toBe(false);
|
|
expect(r.failure).not.toBeNull();
|
|
expect(r.failure!.phase).toBe("duration");
|
|
expect(r.failure!.kind).toBe("mismatch");
|
|
});
|
|
});
|