Skip to content

Commit f198434

Browse files
committed
add vitest
1 parent 3065ede commit f198434

File tree

3 files changed

+618
-2
lines changed

3 files changed

+618
-2
lines changed

packages/typer-diff/index.test.ts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// sum.test.js
2+
import { expect, test } from "vitest";
3+
import { diff } from ".";
4+
5+
test("Test diff", () => {
6+
let d = diff(
7+
"Building mr concerns servants in he outlived am breeding.",
8+
"Building mr conc srvvants i he o am breed."
9+
);
10+
let expected = {
11+
diff: [
12+
{ value: "B", type: "correct" },
13+
{ value: "u", type: "correct" },
14+
{ value: "i", type: "correct" },
15+
{ value: "l", type: "correct" },
16+
{ value: "d", type: "correct" },
17+
{ value: "i", type: "correct" },
18+
{ value: "n", type: "correct" },
19+
{ value: "g", type: "correct" },
20+
{ value: " ", type: "spacer" },
21+
{ value: "m", type: "correct" },
22+
{ value: "r", type: "correct" },
23+
{ value: " ", type: "spacer" },
24+
{ value: "c", type: "correct" },
25+
{ value: "o", type: "correct" },
26+
{ value: "n", type: "correct" },
27+
{ value: "c", type: "correct" },
28+
{ value: "e", type: "missing" },
29+
{ value: "r", type: "missing" },
30+
{ value: "n", type: "missing" },
31+
{ value: "s", type: "missing" },
32+
{ value: " ", type: "spacer" },
33+
{ value: "s", type: "correct" },
34+
{ value: "r", type: "wrong" },
35+
{ value: "v", type: "wrong" },
36+
{ value: "v", type: "correct" },
37+
{ value: "a", type: "correct" },
38+
{ value: "n", type: "correct" },
39+
{ value: "t", type: "correct" },
40+
{ value: "s", type: "correct" },
41+
{ value: " ", type: "spacer" },
42+
{ value: "i", type: "correct" },
43+
{ value: "n", type: "missing" },
44+
{ value: " ", type: "spacer" },
45+
{ value: "h", type: "correct" },
46+
{ value: "e", type: "correct" },
47+
{ value: " ", type: "spacer" },
48+
{ value: "o", type: "correct" },
49+
{ value: "u", type: "missing" },
50+
{ value: "t", type: "missing" },
51+
{ value: "l", type: "missing" },
52+
{ value: "i", type: "missing" },
53+
{ value: "v", type: "missing" },
54+
{ value: "e", type: "missing" },
55+
{ value: "d", type: "missing" },
56+
{ value: " ", type: "spacer" },
57+
{ value: "a", type: "correct" },
58+
{ value: "m", type: "correct" },
59+
{ value: " ", type: "spacer" },
60+
{ value: "b", type: "correct" },
61+
{ value: "r", type: "correct" },
62+
{ value: "e", type: "correct" },
63+
{ value: "e", type: "correct" },
64+
{ value: "d", type: "correct" },
65+
{ value: ".", type: "wrong" },
66+
{ value: "n", type: "untouched" },
67+
{ value: "g", type: "untouched" },
68+
{ value: ".", type: "untouched" },
69+
{ value: " ", type: "spacer" },
70+
],
71+
end: false,
72+
};
73+
expect(d).toStrictEqual(expected);
74+
});

packages/typer-diff/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
"build": "tsup index.ts --format cjs,esm --dts --minify",
2828
"dev": "tsup index.ts --format cjs,esm --dts --watch",
2929
"lint": "tsc",
30-
"release": "pnpm run build && pnpm publish"
30+
"release": "pnpm run build && pnpm test && pnpm run publish",
31+
"test": "vitest"
3132
},
3233
"dependencies": {
3334
"typescript": "^5.5.2"
3435
},
3536
"devDependencies": {
36-
"tsup": "^8.1.0"
37+
"@vitest/coverage-v8": "^1.6.0",
38+
"tsup": "^8.1.0",
39+
"vitest": "^1.6.0"
3740
}
3841
}

0 commit comments

Comments
 (0)