-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab-blocks-plugin.test.js
83 lines (60 loc) · 2.02 KB
/
tab-blocks-plugin.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import fs from "node:fs";
import path from "node:path";
import remark from "remark";
import remarkMdx from "remark-mdx";
afterEach(() => {
jest.resetModules();
});
async function processFixture(fixture, options) {
const tabBlocksPlugin = (await import("../")).default;
const filePath = path.join(__dirname, "__fixtures__", `${fixture}.md`);
const file = fs.readFileSync(filePath);
const result = await remark()
.use(remarkMdx)
.use(tabBlocksPlugin, options)
.process(file);
return result.toString();
}
describe("tab blocks plugin", () => {
test("base example", async () => {
const result = await processFixture("base");
expect(result).toMatchSnapshot();
});
test("full example", async () => {
const result = await processFixture("full-example");
expect(result).toMatchSnapshot();
});
test("can be nested inside an admonition", async () => {
const result = await processFixture("inside-admonition");
expect(result).toMatchSnapshot();
});
test("respects title meta", async () => {
const result = await processFixture("title");
expect(result).toMatchSnapshot();
});
test("supports custom labels", async () => {
const result = await processFixture("label", {
labels: [
["js", "javascript"],
["py", "Python"],
],
});
expect(result).toMatchSnapshot();
});
test("supports span meta", async () => {
const result = await processFixture("span");
expect(result).toMatchSnapshot();
});
test("ignores incomplete spans", async () => {
const result = await processFixture("span-incomplete");
expect(result).toMatchSnapshot();
});
test("does not re-import tabs components when already imported above", async () => {
const result = await processFixture("import-tabs-above");
expect(result).toMatchSnapshot();
});
test("does not re-import tabs components when already imported below", async () => {
const result = await processFixture("import-tabs-below");
expect(result).toMatchSnapshot();
});
});