Skip to content

Commit 37cbabf

Browse files
committed
assertSnapshot()に頼り切りにならない実装にした
1 parent 5b53e79 commit 37cbabf

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

rest/getCodeBlocks.test.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference lib="deno.ns" />
22

33
import { Line } from "../deps/scrapbox-rest.ts";
4-
import { assertSnapshot } from "../deps/testing.ts";
4+
import { assertEquals, assertSnapshot } from "../deps/testing.ts";
55
import { getCodeBlocks } from "./getCodeBlocks.ts";
66

77
// https://scrapbox.io/takker/コードブロック記法
@@ -234,15 +234,27 @@ Deno.test("getCodeBlocks()", async (t) => {
234234
await getCodeBlocks({ project, title, lines: sample }),
235235
);
236236
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,
239240
});
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);
241247
});
242248
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,
245252
});
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);
247259
});
248260
});

0 commit comments

Comments
 (0)