diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cli/install/bad-workspace.test.ts | 6 | ||||
-rw-r--r-- | test/cli/install/bun-add.test.ts | 4 | ||||
-rw-r--r-- | test/cli/install/bun-install.test.ts | 55 |
3 files changed, 56 insertions, 9 deletions
diff --git a/test/cli/install/bad-workspace.test.ts b/test/cli/install/bad-workspace.test.ts index 1feafc2b0..bd8f0b24d 100644 --- a/test/cli/install/bad-workspace.test.ts +++ b/test/cli/install/bad-workspace.test.ts @@ -12,7 +12,7 @@ test("bad workspace path", () => { JSON.stringify( { name: "hey", - workspaces: ["i-dont-exist", "*/i-have-a-star-and-i-dont-exist"], + workspaces: ["i-dont-exist", "**/i-have-a-2-stars-and-i-dont-exist", "*/i-have-a-star-and-i-dont-exist"], }, null, 2, @@ -28,7 +28,9 @@ test("bad workspace path", () => { const text = stderr!.toString(); expect(text).toContain('Workspace not found "i-dont-exist"'); - expect(text).toContain('Workspace not found "*/i-have-a-star-and-i-dont-exist"'); + expect(text).toContain("multi level globs"); + expect(text).toContain("glob star * in the middle of a path"); + expect(exitCode).toBe(1); rmSync(cwd, { recursive: true, force: true }); }); diff --git a/test/cli/install/bun-add.test.ts b/test/cli/install/bun-add.test.ts index d1222993b..310341560 100644 --- a/test/cli/install/bun-add.test.ts +++ b/test/cli/install/bun-add.test.ts @@ -366,7 +366,7 @@ it("should add dependency alongside workspaces", async () => { JSON.stringify({ name: "foo", version: "0.0.1", - workspaces: ["packages/bar"], + workspaces: ["packages/*"], }), ); await mkdir(join(package_dir, "packages", "bar"), { recursive: true }); @@ -417,7 +417,7 @@ it("should add dependency alongside workspaces", async () => { expect(await file(join(package_dir, "package.json")).json()).toEqual({ name: "foo", version: "0.0.1", - workspaces: ["packages/bar"], + workspaces: ["packages/*"], dependencies: { baz: "^0.0.3", }, diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index d722a15fb..bdb5053c3 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -212,7 +212,7 @@ it("should handle workspaces", async () => { JSON.stringify({ name: "Foo", version: "0.0.1", - workspaces: ["bar"], + workspaces: ["bar", "packages/*"], }), ); await mkdir(join(package_dir, "bar")); @@ -223,6 +223,34 @@ it("should handle workspaces", async () => { version: "0.0.2", }), ); + + await mkdir(join(package_dir, "packages", "nominally-scoped"), { recursive: true }); + await writeFile( + join(package_dir, "packages", "nominally-scoped", "package.json"), + JSON.stringify({ + name: "@org/nominally-scoped", + version: "0.1.4", + }), + ); + + await mkdir(join(package_dir, "packages", "second-asterisk"), { recursive: true }); + await writeFile( + join(package_dir, "packages", "second-asterisk", "package.json"), + JSON.stringify({ + name: "AsteriskTheSecond", + version: "0.1.4", + }), + ); + + await mkdir(join(package_dir, "packages", "asterisk"), { recursive: true }); + await writeFile( + join(package_dir, "packages", "asterisk", "package.json"), + JSON.stringify({ + name: "Asterisk", + version: "0.0.4", + }), + ); + const { stdout, stderr, exited } = spawn({ cmd: [bunExe(), "install"], cwd: package_dir, @@ -237,14 +265,30 @@ it("should handle workspaces", async () => { expect(stdout).toBeDefined(); const out = await new Response(stdout).text(); expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + " + @org/nominally-scoped@workspace:packages/nominally-scoped", + " + Asterisk@workspace:packages/asterisk", + " + AsteriskTheSecond@workspace:packages/second-asterisk", " + Bar@workspace:bar", "", - " 1 packages installed", + " 4 packages installed", ]); expect(await exited).toBe(0); expect(requested).toBe(0); - expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([".cache", "Bar"]); + expect(await readdirSorted(join(package_dir, "node_modules"))).toEqual([ + ".cache", + "@org", + "Asterisk", + "AsteriskTheSecond", + "Bar", + ]); expect(await readlink(join(package_dir, "node_modules", "Bar"))).toBe(join("..", "bar")); + expect(await readlink(join(package_dir, "node_modules", "Asterisk"))).toBe(join("..", "packages", "asterisk")); + expect(await readlink(join(package_dir, "node_modules", "AsteriskTheSecond"))).toBe( + join("..", "packages", "second-asterisk"), + ); + expect(await readlink(join(package_dir, "node_modules", "@org", "nominally-scoped"))).toBe( + join("..", "..", "packages", "nominally-scoped"), + ); await access(join(package_dir, "bun.lockb")); }); @@ -2290,8 +2334,9 @@ it("should report error on duplicated workspace packages", async () => { "", 'error: Workspace name "moo" already exists', '{"name":"foo","version":"0.0.1","workspaces":["bar","baz"]}', - " ^", - `${package_dir}/package.json:1:53 52`, + // we don't have a name location anymore + "^", + `${package_dir}/package.json:1:1 0`, "", ]); expect(stdout).toBeDefined(); |