36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { demoInspection } from "./demo";
|
|
import { inspectionToMarkdown } from "./report";
|
|
|
|
describe("report export", () => {
|
|
it("exports the health score, findings and normalized evidence", () => {
|
|
const report = inspectionToMarkdown(demoInspection);
|
|
expect(report).toContain("# CertScope report — portfolio-demo.invalid");
|
|
expect(report).toContain("Overall health: 98/100");
|
|
expect(report).toContain("Score formula: equal-weighted average");
|
|
expect(report).toContain("Completeness: complete (3/3 collectors complete)");
|
|
expect(report).toContain("- DNS: ok");
|
|
expect(report).toContain("Content-Security-Policy is missing");
|
|
expect(report).toContain("## DNS evidence");
|
|
expect(report).toContain("## TLS evidence");
|
|
expect(report).toContain("## HTTP evidence");
|
|
});
|
|
|
|
it("escapes finding text and keeps JSON evidence fences safe", () => {
|
|
const report = inspectionToMarkdown({
|
|
...demoInspection,
|
|
findings: [{
|
|
...demoInspection.findings[0],
|
|
title: "Injected *title* [value]",
|
|
summary: "line one\nline two",
|
|
}],
|
|
http: { ...demoInspection.http, injected: "```\nnot a markdown fence" },
|
|
});
|
|
|
|
expect(report).toContain("### Injected \\*title\\* \\[value\\]");
|
|
expect(report).toContain("- Summary: line one line two");
|
|
expect(report).toContain("injected");
|
|
expect(report.match(/^`{3,}(json)?$/gm)?.length).toBe(6);
|
|
});
|
|
});
|