Skip to content

Commit ad4f8e3

Browse files
committed
test: add test for local tarball package
1 parent 1cfc28e commit ad4f8e3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/extract-package-api.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { join } from "pathe";
12
import { expect, test } from "vitest";
23
import { extractPackageApi } from "./extract-package-api";
34

@@ -7,23 +8,34 @@ test("invalid package name", async () => {
78
expect(process.cwd()).toBe(startDir);
89
});
910

10-
test("package not found", async () => {
11+
test("npm package not found", async () => {
1112
const startDir = process.cwd();
1213
await expect(extractPackageApi({ pkg: "@jsdocs-io/not-found" })).rejects.toThrow();
1314
expect(process.cwd()).toBe(startDir);
1415
});
1516

16-
test("package types not found", async () => {
17+
test("npm package types not found", async () => {
1718
const startDir = process.cwd();
1819
await expect(extractPackageApi({ pkg: "unlicensed@0.4.0" })).rejects.toThrow();
1920
expect(process.cwd()).toBe(startDir);
2021
});
2122

22-
test("package successfully analyzed", async () => {
23+
test("npm package successfully analyzed", async () => {
2324
const startDir = process.cwd();
2425
await expect(extractPackageApi({ pkg: "short-time-ago@2.0.0" })).resolves.toMatchObject({
2526
name: "short-time-ago",
2627
version: "2.0.0",
2728
});
2829
expect(process.cwd()).toBe(startDir);
2930
});
31+
32+
test("local tarball package successfully analyzed", async () => {
33+
const startDir = process.cwd();
34+
await expect(
35+
extractPackageApi({ pkg: join(startDir, "tarballs/short-time-ago-3.0.0.tgz") }),
36+
).resolves.toMatchObject({
37+
name: "short-time-ago",
38+
version: "3.0.0",
39+
});
40+
expect(process.cwd()).toBe(startDir);
41+
});

tarballs/short-time-ago-3.0.0.tgz

3.18 KB
Binary file not shown.

0 commit comments

Comments
 (0)