From 525798aa4db3cf30521b70ac9581e19d94a97abb Mon Sep 17 00:00:00 2001 From: Peter Li Date: Fri, 17 Jul 2026 08:32:09 +0800 Subject: [PATCH] test: harden playground structure assertions --- tests/link-vault.test.mjs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/link-vault.test.mjs b/tests/link-vault.test.mjs index 5d90b44..2916a39 100644 --- a/tests/link-vault.test.mjs +++ b/tests/link-vault.test.mjs @@ -148,9 +148,10 @@ test("the playground fixture covers the supported Markdown elements", async () = assert.match(playground, /^已解析链接:\[\[Embedded Note\]\]$/m); assert.match(playground, /^未解析链接:\[\[Missing Note\]\]$/m); assert.match(playground, /^外部链接:\[Obsidian\]\(https:\/\/obsidian\.md\)$/m); - assert.match(playground, /^> 第一行引用,用于检查纸张折角。$/m); - assert.match(playground, /^> 第二行引用,用于检查连续卡片。$/m); - assert.match(playground, /^> > 嵌套引用只保留外层折角。$/m); + assert.match( + playground, + /^> 第一行引用,用于检查纸张折角。\n> 第二行引用,用于检查连续卡片。\n> > 嵌套引用只保留外层折角。$/m, + ); assert.match(playground, /^1\. 有序列表项$/m); assert.match(playground, /^ 1\. 嵌套有序列表项$/m); assert.match(playground, /^2\. 另一个有序列表项$/m); @@ -159,16 +160,9 @@ test("the playground fixture covers the supported Markdown elements", async () = assert.match(playground, /^- 另一个无序列表项$/m); assert.match(playground, /^- \[x\] 已完成任务$/m); assert.match(playground, /^- \[ \] 待完成任务$/m); - assert.match(playground, /^```javascript$/m); - assert.match(playground, /^\/\/ Monokai syntax coverage$/m); - assert.match(playground, /^const accent = "#1677FF";$/m); - assert.match(playground, /^function renderTheme\(name, retries = 3\) \{$/m); - assert.match(playground, /^ return `\$\{name\}:\$\{retries\}`;$/m); - assert.match(playground, /^\}$/m); - assert.match(playground, /^renderTheme\("Aera"\);$/m); assert.match( playground, - /^const horizontalScroll = "This intentionally long JavaScript line verifies horizontal scrolling without wrapping in the Aera code block playground\.";$/m, + /^```javascript\n\/\/ Monokai syntax coverage\nconst accent = "#1677FF";\nfunction renderTheme\(name, retries = 3\) \{\n return `\$\{name\}:\$\{retries\}`;\n\}\nrenderTheme\("Aera"\);\nconst horizontalScroll = "This intentionally long JavaScript line verifies horizontal scrolling without wrapping in the Aera code block playground\.";\n```(?=\n\n```\n无语言代码块用于检查普通文本。\n```$)/m, ); assert.equal(playground.match(/^---$/gm)?.length, 3); assert.match( @@ -187,7 +181,10 @@ test("the playground fixture covers the supported Markdown elements", async () = "quote", "tip", ]) { - assert.match(playground, new RegExp(`^> \\[!${calloutType}\\]`, "m")); + assert.match( + playground, + new RegExp(`^> \\[!${calloutType}\\](?:[+-])?(?: .*)?$`, "m"), + ); } assert.match(playground, /^> \[!tip\]- 收起的提示$/m); assert.match(playground, /^\| 元素 \| 状态 \| 用途 \|$/m);