Open History to see the last commit
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 top-level and blockquoted ordered-list markers", () => {
21 expect(hasWideMarkdownBlock("1. One\n2. Two\n3. Three\n4. Four\n5. Five")).toBe(true);
22 expect(hasWideMarkdownBlock("before\n3) Three")).toBe(true);
23 expect(hasWideMarkdownBlock("> 1. One\n> 2. Two")).toBe(true);
24 expect(hasWideMarkdownBlock("> > 3) Three")).toBe(true);
25 });
26
27 it("detects nested ordered lists without treating indented code as a list", () => {
28 expect(hasWideMarkdownBlock("- Parent\n 1. Child\n 2. Child")).toBe(true);
29 expect(hasWideMarkdownBlock("> - Parent\n> 1. Child")).toBe(true);
30 expect(hasWideMarkdownBlock(" 1. indented code")).toBe(false);
31 expect(hasWideMarkdownBlock(" - code-like bullet\n 1. indented code")).toBe(false);
32 });
33
34 it("can limit ordered-list width pinning to Android", () => {
35 const orderedList = "1. One\n2. Two";
36 expect(hasWideMarkdownBlock(orderedList, { includeOrderedLists: true })).toBe(true);
37 expect(hasWideMarkdownBlock(orderedList, { includeOrderedLists: false })).toBe(false);
38 expect(hasWideMarkdownBlock("```\ncode\n```", { includeOrderedLists: false })).toBe(true);
39 expect(hasWideMarkdownBlock("| a | b |\n| --- | --- |", { includeOrderedLists: false })).toBe(
40 true,
41 );
42 });
43
44 it("detects GFM tables", () => {
45 expect(hasWideMarkdownBlock("| a | b |\n| --- | --- |\n| 1 | 2 |")).toBe(true);
46 expect(hasWideMarkdownBlock("a | b\n:-- | --:\n1 | 2")).toBe(true);
47 });
48});