import { afterEach, describe, expect, test } from "bun:test" import { mkdtempSync, rmSync, writeFileSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" import { validateReportDocument } from "./validate.js" const valid = "# 报告\n\n| 报告信息 | 内容 |\n| --- | --- |\n| 报告编号 | TEST |\n| 客户名称 | 企业 |\n| 统计期间 | 2026-08 |\n| 报告状态 | 草稿 |\n| 生成日期 | 2026-10-12 |\n" const dirs: string[] = [] afterEach(() => { for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true, force: true }) }) function check(content: string) { const dir = mkdtempSync(join(tmpdir(), "seal-validator-test-")) dirs.push(dir) const file = join(dir, "report.md") writeFileSync(file, content) return validateReportDocument(file) } describe("native report validator", () => { test("valid information and CRLF have the same clean result", () => { expect(check(valid)).toMatchObject({ valid: true, tables: 1, figures: 0, issues: [] }) expect(check(valid.replaceAll("\n", "\r\n"))).toMatchObject({ valid: true, issues: [] }) }) test.each(["