Files

28 lines
898 B
TypeScript

import { describe, expect, it } from "vitest";
import { inertFences } from "$lib/panel/fences";
const runs = (language: string) => ["tasks", "dataview"].includes(language);
describe("inertFences", () => {
it("turns a query block into code", () => {
expect(inertFences("```tasks\nnot done\n```", runs)).toBe(
"```text\nnot done\n```"
);
expect(inertFences("~~~Dataview\nlist\n~~~", runs)).toBe(
"~~~text\nlist\n~~~"
);
});
it("reaches a block opened inside a list item or a quote", () => {
expect(inertFences("+ ```tasks\n+ not done", runs)).toBe(
"+ ```text\n+ not done"
);
expect(inertFences("> 1. ````tasks {x}", runs)).toBe("> 1. ````text {x}");
});
it("leaves ordinary code and closing fences alone", () => {
const text = "```python\nprint(1)\n```\ninline `tasks` stays";
expect(inertFences(text, runs)).toBe(text);
});
});