test.govlab/quality/core/parsers/tool.jscpd.parser.test.ts
test.govlab/quality/core/parsers/tool.jscpd.parser.test.ts is a file in Codebase Testing. 17 lines of code and 0 definitions.
import { expect, test } from "vitest";
import { parseJscpdOutput } from "@govlab/quality/core/parsers/tool.jscpd.parser.ts";
const SECOND_LINE = 9;
test("parseJscpdOutput reports each clone at its second copy and names the first", () => {
const stdout = JSON.stringify({
duplicates: [
{
firstFile: { name: "a.ts", start: { line: 3 } },
secondFile: { name: "b.ts", start: { line: SECOND_LINE } },
},
],
});
const [finding] = parseJscpdOutput(stdout, "typescript");
expect(finding).toMatchObject({ file: "b.ts", line: SECOND_LINE, ruleId: "jscpd/duplicate", tool: "jscpd" });
expect(finding?.message).toContain("a.ts:3");
expect(parseJscpdOutput("not json", "typescript")).toStrictEqual([]);
});