Skip to content

Commit 3a89488

Browse files
committed
test: add tests for Bun
1 parent 4a704ea commit 3a89488

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/node": "^24.9.1",
2424
"@types/validate-npm-package-name": "^4.0.2",
2525
"@vitest/coverage-v8": "^4.0.3",
26+
"go-go-try": "^6.2.0",
2627
"np": "^10.2.0",
2728
"prettier-plugin-organize-imports": "^4.3.0",
2829
"ts-dedent": "^2.2.0",
@@ -409,6 +410,8 @@
409410

410411
"globby": ["globby@14.1.0", "", { "dependencies": { "@sindresorhus/merge-streams": "^2.1.0", "fast-glob": "^3.3.3", "ignore": "^7.0.3", "path-type": "^6.0.0", "slash": "^5.1.0", "unicorn-magic": "^0.3.0" } }, "sha512-0Ia46fDOaT7k4og1PDW4YbodWWr3scS2vAr2lTbsplOt2WkKp0vQbkI9wKis/T5LV/dqPjO3bpS/z6GTJB82LA=="],
411412

413+
"go-go-try": ["go-go-try@6.2.0", "", {}, "sha512-Q1p/HgxdWFkjgjOvBIPf0v5+kCUBSlUMw7p54OmCAdT+F+LujnaE68aFk9z4PL5s/sJvNpe1do9/96JPvoCr6g=="],
414+
412415
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
413416

414417
"has-ansi": ["has-ansi@2.0.0", "", { "dependencies": { "ansi-regex": "^2.0.0" } }, "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg=="],

codebook.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ words = [
77
"cwd",
88
"esm",
99
"execa",
10+
"hcaptcha",
1011
"jsdocs",
1112
"pathe",
1213
"tempy",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"@types/node": "^24.9.1",
8686
"@types/validate-npm-package-name": "^4.0.2",
8787
"@vitest/coverage-v8": "^4.0.3",
88+
"go-go-try": "^6.2.0",
8889
"np": "^10.2.0",
8990
"prettier-plugin-organize-imports": "^4.3.0",
9091
"ts-dedent": "^2.2.0",

src/bun.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { goTry } from "go-go-try";
2+
import { expect, test } from "vitest";
3+
import { Bun } from "./bun.ts";
4+
import { tempDir } from "./temp-dir.ts";
5+
6+
test("optional bunCmd in constructor", () => {
7+
const bun = new Bun();
8+
expect(bun).toBeDefined();
9+
});
10+
11+
test("custom bunCmd in constructor", () => {
12+
const bun = new Bun("bun");
13+
expect(bun).toBeDefined();
14+
});
15+
16+
test("empty pkg", async () => {
17+
await using dir = await tempDir();
18+
const bun = new Bun();
19+
const [err, deps] = await goTry(bun.add("", dir.path));
20+
expect(err).toBeDefined();
21+
expect(deps).toBeUndefined();
22+
});
23+
24+
test("package with no dependencies", async () => {
25+
await using dir = await tempDir();
26+
const bun = new Bun();
27+
const [err, deps] = await goTry(bun.add("verify-hcaptcha@1.0.0", dir.path));
28+
expect(err).toBeUndefined();
29+
expect(deps).toMatchInlineSnapshot(`
30+
[
31+
"verify-hcaptcha@1.0.0",
32+
]
33+
`);
34+
});
35+
36+
test("package with some dependencies", async () => {
37+
await using dir = await tempDir();
38+
const bun = new Bun();
39+
const [err, deps] = await goTry(bun.add("query-registry@4.2.0", dir.path));
40+
expect(err).toBeUndefined();
41+
expect(deps).toBeDefined();
42+
expect(deps).toContain("query-registry@4.2.0");
43+
expect(deps!.length).toBeGreaterThan(1);
44+
});

0 commit comments

Comments
 (0)