Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

wideMarkdownBlocks.test.ts

24 lines1.0 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { hasWideMarkdownBlock } from "./wideMarkdownBlocks";
4​
5describe("hasWideMarkdownBlock", () => {
6 it("ignores prose, inline code, and emphasis", () => {
7 expect(hasWideMarkdownBlock("just a message")).toBe(false);
8 expect(hasWideMarkdownBlock("I found it in `secteurs_intervention` earlier")).toBe(false);
9 expect(hasWideMarkdownBlock("a | b in a sentence")).toBe(false);
10 expect(hasWideMarkdownBlock("an em dash — and a rule\n\n---\n")).toBe(false);
11 });
12​
13 it("detects fenced code blocks", () => {
14 expect(hasWideMarkdownBlock("before\n```\ncode\n```\nafter")).toBe(true);
15 expect(hasWideMarkdownBlock("before\n```ts\ncode\n```")).toBe(true);
16 expect(hasWideMarkdownBlock("before\n~~~\ncode\n~~~")).toBe(true);
17 expect(hasWideMarkdownBlock(" ```\ncode\n```")).toBe(true);
18 });
19​
20 it("detects GFM tables", () => {
21 expect(hasWideMarkdownBlock("| a | b |\n| --- | --- |\n| 1 | 2 |")).toBe(true);
22 expect(hasWideMarkdownBlock("a | b\n:-- | --:\n1 | 2")).toBe(true);
23 });
24});