Skip to content

Commit 378d89c

Browse files
committed
use Node.js Test Runner
1 parent 5cf78b9 commit 378d89c

25 files changed

+310
-307
lines changed

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.6.0

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"build:types": "tsc -p ./tsconfig.json",
2121
"build:vite": "vite build",
2222
"prepare": "npm run build",
23-
"test": "vitest run --coverage",
24-
"test:update": "vitest run --updateSnapshot --no-cache",
23+
"test": "NODE_OPTIONS=--disable-warning=ExperimentalWarning node --test --experimental-strip-types --experimental-test-snapshots --experimental-test-coverage **/tests/**/*.test.ts",
24+
"test:update": "NODE_OPTIONS=--disable-warning=ExperimentalWarning node --test --experimental-strip-types --experimental-test-snapshots --test-update-snapshots --experimental-test-coverage **/tests/**/*.test.ts",
2525
"lint": "run-p lint:*",
2626
"lint:biome": "biome check .",
2727
"lint:tsc": "tsc -p ./tsconfig.lint.json",

tests/codeBlock/index.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import { parse } from "../../src/index.ts";
33

44
describe("Code Block", () => {
5-
it("Simple code block", () => {
6-
expect(
5+
it("Simple code block", ({ assert }) => {
6+
assert.snapshot(
77
parse(
88
`
99
code:hello.js
@@ -15,11 +15,11 @@ code:hello.js
1515
`.trim(),
1616
{ hasTitle: false },
1717
),
18-
).toMatchSnapshot();
18+
);
1919
});
2020

21-
it("Bulleted code block", () => {
22-
expect(
21+
it("Bulleted code block", ({ assert }) => {
22+
assert.snapshot(
2323
parse(
2424
` code:hello.js
2525
function () {
@@ -29,11 +29,11 @@ code:hello.js
2929
}`,
3030
{ hasTitle: false },
3131
),
32-
).toMatchSnapshot();
32+
);
3333
});
3434

35-
it("Code block with bullet", () => {
36-
expect(
35+
it("Code block with bullet", ({ assert }) => {
36+
assert.snapshot(
3737
parse(
3838
` Bullet
3939
code:hello.js
@@ -45,11 +45,11 @@ code:hello.js
4545
Bullet`,
4646
{ hasTitle: false },
4747
),
48-
).toMatchSnapshot();
48+
);
4949
});
5050

51-
it("Consecutive code blocks", () => {
52-
expect(
51+
it("Consecutive code blocks", ({ assert }) => {
52+
assert.snapshot(
5353
parse(
5454
`
5555
code:hello.js
@@ -67,6 +67,6 @@ code:hello.js
6767
`.trim(),
6868
{ hasTitle: false },
6969
),
70-
).toMatchSnapshot();
70+
);
7171
});
7272
});

tests/line/blank.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
/* eslint-disable no-irregular-whitespace */
2-
import { describe, expect, it } from "vitest";
2+
import { describe, it } from "node:test";
33
import { parse } from "../../src/index.ts";
44

55
describe("blank", () => {
6-
it("Simple half-space blank", () => {
7-
expect(parse("[ ]", { hasTitle: false })).toMatchSnapshot();
6+
it("Simple half-space blank", ({ assert }) => {
7+
assert.snapshot(parse("[ ]", { hasTitle: false }));
88
});
99

10-
it("Simple double-byte space blank", () => {
11-
expect(parse("[ ]", { hasTitle: false })).toMatchSnapshot();
10+
it("Simple double-byte space blank", ({ assert }) => {
11+
assert.snapshot(parse("[ ]", { hasTitle: false }));
1212
});
1313

14-
it("Simple tab blank", () => {
15-
expect(parse("[\t]", { hasTitle: false })).toMatchSnapshot();
14+
it("Simple tab blank", ({ assert }) => {
15+
assert.snapshot(parse("[\t]", { hasTitle: false }));
1616
});
1717

18-
it("Multi char blank", () => {
19-
expect(parse("[   \t \t ]", { hasTitle: false })).toMatchSnapshot();
18+
it("Multi char blank", ({ assert }) => {
19+
assert.snapshot(parse("[   \t \t ]", { hasTitle: false }));
2020
});
2121

22-
it("Blank in the sentence", () => {
23-
expect(
22+
it("Blank in the sentence", ({ assert }) => {
23+
assert.snapshot(
2424
parse("sentence[ ]sentence", {
2525
hasTitle: false,
2626
}),
27-
).toMatchSnapshot();
27+
);
2828
});
2929

30-
it("[] is not blank", () => {
31-
expect(parse("[]", { hasTitle: false })).toMatchSnapshot();
30+
it("[] is not blank", ({ assert }) => {
31+
assert.snapshot(parse("[]", { hasTitle: false }));
3232
});
3333

34-
it("Blank in the [*** ]", () => {
35-
expect(parse("[*** [ ]]", { hasTitle: false })).toMatchSnapshot();
34+
it("Blank in the [*** ]", ({ assert }) => {
35+
assert.snapshot(parse("[*** [ ]]", { hasTitle: false }));
3636
});
3737
});

tests/line/bullet.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import { parse } from "../../src/index.ts";
33

44
describe("bullet", () => {
5-
it("Single-byte space indent", () => {
6-
expect(
5+
it("Single-byte space indent", ({ assert }) => {
6+
assert.snapshot(
77
parse(" Single-byte space", {
88
hasTitle: false,
99
}),
10-
).toMatchSnapshot();
10+
);
1111
});
1212

13-
it("Double-byte space indent", () => {
14-
expect(
13+
it("Double-byte space indent", ({ assert }) => {
14+
assert.snapshot(
1515
parse(" Double-byte space", {
1616
hasTitle: false,
1717
}),
18-
).toMatchSnapshot();
18+
);
1919
});
2020

21-
it("Tab indent", () => {
21+
it("Tab indent", ({ assert }) => {
2222
// eslint-disable-next-line no-tabs
23-
expect(parse(" Tab", { hasTitle: false })).toMatchSnapshot();
23+
assert.snapshot(parse(" Tab", { hasTitle: false }));
2424
});
2525

26-
it("Multi lines bullet", () => {
27-
expect(
26+
it("Multi lines bullet", ({ assert }) => {
27+
assert.snapshot(
2828
parse(
2929
`
3030
no bullet (indent: 0)
@@ -34,6 +34,6 @@ no bullet (indent: 0)
3434
`.trim(),
3535
{ hasTitle: false },
3636
),
37-
).toMatchSnapshot();
37+
);
3838
});
3939
});

tests/line/code.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import { parse } from "../../src/index.ts";
33

44
describe("code", () => {
5-
it("Simple code with backquote", () => {
6-
expect(parse("`Simple code`", { hasTitle: false })).toMatchSnapshot();
5+
it("Simple code with backquote", ({ assert }) => {
6+
assert.snapshot(parse("`Simple code`", { hasTitle: false }));
77
});
88

9-
it("Empty code with backquote", () => {
10-
expect(parse("``", { hasTitle: false })).toMatchSnapshot();
9+
it("Empty code with backquote", ({ assert }) => {
10+
assert.snapshot(parse("``", { hasTitle: false }));
1111
});
1212
});

tests/line/commandLine.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import { parse } from "../../src/index.ts";
33

44
describe("commandLine", () => {
5-
it("Simple command with $", () => {
6-
expect(parse("$ command", { hasTitle: false })).toMatchSnapshot();
5+
it("Simple command with $", ({ assert }) => {
6+
assert.snapshot(parse("$ command", { hasTitle: false }));
77
});
88

9-
it("Simple command with %", () => {
10-
expect(parse("% command", { hasTitle: false })).toMatchSnapshot();
9+
it("Simple command with %", ({ assert }) => {
10+
assert.snapshot(parse("% command", { hasTitle: false }));
1111
});
1212

13-
it("`$` is not command", () => {
14-
expect(parse("$", { hasTitle: false })).toMatchSnapshot();
13+
it("`$` is not command", ({ assert }) => {
14+
assert.snapshot(parse("$", { hasTitle: false }));
1515
});
1616

17-
it("`$ ` is not command", () => {
18-
expect(parse("$ ", { hasTitle: false })).toMatchSnapshot();
17+
it("`$ ` is not command", ({ assert }) => {
18+
assert.snapshot(parse("$ ", { hasTitle: false }));
1919
});
2020

21-
it("`$s` is not command", () => {
22-
expect(parse("$not command", { hasTitle: false })).toMatchSnapshot();
21+
it("`$s` is not command", ({ assert }) => {
22+
assert.snapshot(parse("$not command", { hasTitle: false }));
2323
});
2424
});

tests/line/decoration.test.ts

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import {
33
type Decoration,
44
type DecorationNode,
@@ -7,8 +7,8 @@ import {
77
} from "../../src/index.ts";
88

99
describe("decoration", () => {
10-
it("Simple decoration", () => {
11-
expect(
10+
it("Simple decoration", ({ assert }) => {
11+
assert.snapshot(
1212
parse(
1313
`
1414
[* deco]
@@ -44,10 +44,10 @@ describe("decoration", () => {
4444
`.trim(),
4545
{ hasTitle: false },
4646
),
47-
).toMatchSnapshot();
47+
);
4848
});
4949

50-
it("All decoration", () => {
50+
it("All decoration", ({ assert }) => {
5151
const input = "[**********!\"#%&'()*+,-./{|}<>_~ decos]";
5252
const blocks = parse(input, { hasTitle: false });
5353
const received = ((blocks[0] as Line).nodes[0] as DecorationNode).decos;
@@ -74,60 +74,62 @@ describe("decoration", () => {
7474
"_",
7575
"~",
7676
];
77-
expect(new Set<Decoration>(received)).toEqual(new Set<Decoration>(decos));
77+
assert.deepStrictEqual(received.sort(), decos.sort());
7878
});
7979

80-
it("Decoration * overflow", () => {
81-
expect(parse("[*********** 11*]", { hasTitle: false })).toMatchSnapshot();
80+
it("Decoration * overflow", ({ assert }) => {
81+
assert.snapshot(parse("[*********** 11*]", { hasTitle: false }));
8282
});
8383

84-
it("Decoration similar with externalLink", () => {
85-
expect(
84+
it("Decoration similar with externalLink", ({ assert }) => {
85+
assert.snapshot(
8686
parse("[* hoge https://example.com]", {
8787
hasTitle: false,
8888
}),
89-
).toMatchSnapshot();
89+
);
9090
});
9191

92-
it("Decoration with hashTag", () => {
93-
expect(
92+
it("Decoration with hashTag", ({ assert }) => {
93+
assert.snapshot(
9494
parse("[* #tag]", {
9595
hasTitle: false,
9696
}),
97-
).toMatchSnapshot();
97+
);
9898
});
9999

100-
it("Decoration with many [", () => {
101-
expect(parse("[! [[[[[[a]", { hasTitle: false })).toMatchSnapshot();
100+
it("Decoration with many [", ({ assert }) => {
101+
assert.snapshot(parse("[! [[[[[[a]", { hasTitle: false }));
102102
});
103103

104-
it("Decoration with many [ and link", () => {
105-
expect(parse("[! [[[[[[a]]", { hasTitle: false })).toMatchSnapshot();
104+
it("Decoration with many [ and link", ({ assert }) => {
105+
assert.snapshot(parse("[! [[[[[[a]]", { hasTitle: false }));
106106
});
107107

108-
it("Decoration with strong notation (it's just link)", () => {
109-
expect(parse("[* [[link]]]", { hasTitle: false })).toMatchSnapshot();
108+
it("Decoration with strong notation (it's just link)", ({ assert }) => {
109+
assert.snapshot(parse("[* [[link]]]", { hasTitle: false }));
110110
});
111111

112-
it("Decoration with icon notation", () => {
113-
expect(
112+
it("Decoration with icon notation", ({ assert }) => {
113+
assert.snapshot(
114114
parse("[* [progfay.icon]]", {
115115
hasTitle: false,
116116
}),
117-
).toMatchSnapshot();
117+
);
118118
});
119119

120-
it("Decoration with strong icon notation (it's just icon, not strong)", () => {
121-
expect(
122-
parse("[* [[progfay.icon]]]", { hasTitle: false }),
123-
).toMatchSnapshot();
120+
it("Decoration with strong icon notation (it's just icon, not strong)", ({
121+
assert,
122+
}) => {
123+
assert.snapshot(parse("[* [[progfay.icon]]]", { hasTitle: false }));
124124
});
125125

126-
it("Decoration with strong image notation (it's just image, not strong)", () => {
127-
expect(
126+
it("Decoration with strong image notation (it's just image, not strong)", ({
127+
assert,
128+
}) => {
129+
assert.snapshot(
128130
parse("[* [[https://example.com/image.png]]]", {
129131
hasTitle: false,
130132
}),
131-
).toMatchSnapshot();
133+
);
132134
});
133135
});

tests/line/formula.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { describe, expect, it } from "vitest";
1+
import { describe, it } from "node:test";
22
import { parse } from "../../src/index.ts";
33

44
describe("formula", () => {
5-
it("Simple formula", () => {
6-
expect(
5+
it("Simple formula", ({ assert }) => {
6+
assert.snapshot(
77
parse("[$ \\frac{3}{2}^N]", {
88
hasTitle: false,
99
}),
10-
).toMatchSnapshot();
10+
);
1111
});
1212

13-
it("Formula includes [] with tail half-space", () => {
14-
expect(parse("[$ [x] ]", { hasTitle: false })).toMatchSnapshot();
13+
it("Formula includes [] with tail half-space", ({ assert }) => {
14+
assert.snapshot(parse("[$ [x] ]", { hasTitle: false }));
1515
});
1616

17-
it("Formula includes [] without tail half-space", () => {
18-
expect(parse("[$ [x]]", { hasTitle: false })).toMatchSnapshot();
17+
it("Formula includes [] without tail half-space", ({ assert }) => {
18+
assert.snapshot(parse("[$ [x]]", { hasTitle: false }));
1919
});
2020
});

0 commit comments

Comments
 (0)