|
1 | 1 | /// <reference lib="deno.ns" /> |
2 | 2 |
|
3 | 3 | import { Line } from "../deps/scrapbox-rest.ts"; |
4 | | -import { assertSnapshot } from "../deps/testing.ts"; |
| 4 | +import { assertEquals, assertSnapshot } from "../deps/testing.ts"; |
5 | 5 | import { getCodeBlocks } from "./getCodeBlocks.ts"; |
6 | 6 |
|
7 | 7 | // https://scrapbox.io/takker/コードブロック記法 |
@@ -234,15 +234,27 @@ Deno.test("getCodeBlocks()", async (t) => { |
234 | 234 | await getCodeBlocks({ project, title, lines: sample }), |
235 | 235 | ); |
236 | 236 | await t.step("filename filter", async (st) => { |
237 | | - const codeBlock = await getCodeBlocks({ project, title, lines: sample }, { |
238 | | - filename: "インデント.md", |
| 237 | + const filename = "インデント.md"; |
| 238 | + const codeBlocks = await getCodeBlocks({ project, title, lines: sample }, { |
| 239 | + filename, |
239 | 240 | }); |
240 | | - await assertSnapshot(st, codeBlock); |
| 241 | + const yet = []; |
| 242 | + for (const codeBlock of codeBlocks) { |
| 243 | + yet.push(assertEquals(codeBlock.filename, filename)); |
| 244 | + } |
| 245 | + await Promise.all(yet); |
| 246 | + await assertSnapshot(st, codeBlocks); |
241 | 247 | }); |
242 | 248 | await t.step("language name filter", async (st) => { |
243 | | - const codeBlock = await getCodeBlocks({ project, title, lines: sample }, { |
244 | | - lang: "py", |
| 249 | + const lang = "py"; |
| 250 | + const codeBlocks = await getCodeBlocks({ project, title, lines: sample }, { |
| 251 | + lang, |
245 | 252 | }); |
246 | | - await assertSnapshot(st, codeBlock); |
| 253 | + const yet = []; |
| 254 | + for (const codeBlock of codeBlocks) { |
| 255 | + yet.push(assertEquals(codeBlock.lang, lang)); |
| 256 | + } |
| 257 | + await Promise.all(yet); |
| 258 | + await assertSnapshot(st, codeBlocks); |
247 | 259 | }); |
248 | 260 | }); |
0 commit comments