import diff from "comark-diff"; import { expect, it } from "vite-plus/test"; import { lint } from "../src/index.ts"; it("locates pull and scope diagnostics after valid blocks, including duplicate mistakes", async () => { const markdown = [ "---", "title: A review", "---", "", "::pull", ":::scope{title=Changes}", "```diff", "--- a/file.ts", "+++ b/file.ts", "@@ -1 +1 @@", "-old", "+new", "```", ":::", "::", "", "::pull{tilte=x}", ":::scope{tilte=x}", "```ts", "const a = 1", "```", ":::", "::", "", "::pull{tilte=x}", "```ts", "const a = 1", "```", "::", "", ":::scope{title=Outside}", "Content", ":::", ].join("\n"); const diagnostics = (await lint(markdown, { plugins: [diff()] })) .filter(({ rule }) => rule.startsWith("comark/diff/")) .map(({ rule, line }) => `${line}:${rule.slice("comark/diff/".length)}`); expect(diagnostics.sort()).toEqual([ "17:pull-missing-diff", "17:pull-unknown-prop", "18:pull-unknown-prop", "18:pull-unreadable-diff", "18:scope-missing-title", "25:pull-missing-diff", "25:pull-unknown-prop", "25:pull-unreadable-diff", "31:scope-outside-pull", ]); });