Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions src/lockfile.unit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { describe, expect, test } from "bun:test";
import { readFileSync } from "fs";
import { resolve } from "path";

// Load and parse the package-lock.json relative to the project root
const lockfilePath = resolve(import.meta.dir, "../package-lock.json");
const lockfile = JSON.parse(readFileSync(lockfilePath, "utf-8"));

describe("package-lock.json version constraints (PR #changes)", () => {
describe("root package version", () => {
test("top-level version is 0.2.6", () => {
expect(lockfile.version).toBe("0.2.6");

Check failure on line 12 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "0.2.6" Received: "0.2.9" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:12:32)
});

test("packages[''] version matches top-level version", () => {
expect(lockfile.packages[""].version).toBe(lockfile.version);
});
});

describe("@tauri-apps/plugin-process dependency constraint", () => {
test("root package declares constraint ^2.3.1", () => {
const deps = lockfile.packages[""].dependencies;
expect(deps["@tauri-apps/plugin-process"]).toBe("^2.3.1");

Check failure on line 23 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "^2.3.1" Received: "~2" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:23:50)
});

test("resolved module version is 2.3.1", () => {
const resolved =
lockfile.packages["node_modules/@tauri-apps/plugin-process"];
expect(resolved.version).toBe("2.3.1");
});

test("constraint uses caret range (not tilde)", () => {
const constraint =
lockfile.packages[""].dependencies["@tauri-apps/plugin-process"];
expect(constraint.startsWith("^")).toBe(true);

Check failure on line 35 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: true Received: false at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:35:42)
expect(constraint.startsWith("~")).toBe(false);
});
});

describe("@tauri-apps/plugin-updater dependency constraint", () => {
test("root package declares constraint ^2.10.0", () => {
const deps = lockfile.packages[""].dependencies;
expect(deps["@tauri-apps/plugin-updater"]).toBe("^2.10.0");

Check failure on line 43 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "^2.10.0" Received: "~2" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:43:50)
});

test("resolved module version is 2.10.0", () => {
const resolved =
lockfile.packages["node_modules/@tauri-apps/plugin-updater"];
expect(resolved.version).toBe("2.10.0");
});

test("constraint uses caret range (not tilde)", () => {
const constraint =
lockfile.packages[""].dependencies["@tauri-apps/plugin-updater"];
expect(constraint.startsWith("^")).toBe(true);

Check failure on line 55 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: true Received: false at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:55:42)
expect(constraint.startsWith("~")).toBe(false);
});
});

describe("cosmiconfig bundled yaml version", () => {
test("cosmiconfig/node_modules/yaml is pinned to 1.10.2", () => {
const yaml =
lockfile.packages["node_modules/cosmiconfig/node_modules/yaml"];
expect(yaml).toBeDefined();
expect(yaml.version).toBe("1.10.2");

Check failure on line 65 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "1.10.2" Received: "1.10.3" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:65:28)
});
});

describe("picomatch version", () => {
test("picomatch resolved version is 4.0.3", () => {
const picomatch = lockfile.packages["node_modules/picomatch"];
expect(picomatch).toBeDefined();
expect(picomatch.version).toBe("4.0.3");

Check failure on line 73 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBe(expected)

Expected: "4.0.3" Received: "4.0.4" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:73:33)
});

test("picomatch entry does not have a resolved field", () => {
// The PR diff removed the 'resolved' field from picomatch
const picomatch = lockfile.packages["node_modules/picomatch"];
expect(picomatch.resolved).toBeUndefined();

Check failure on line 79 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBeUndefined()

Received: "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:79:34)
});

test("picomatch entry does not have an integrity field", () => {
// The PR diff removed the 'integrity' field from picomatch
const picomatch = lockfile.packages["node_modules/picomatch"];
expect(picomatch.integrity).toBeUndefined();

Check failure on line 85 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toBeUndefined()

Received: "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:85:35)
});
});

describe("lockfile structural integrity", () => {
test("lockfile version is 3", () => {
expect(lockfile.lockfileVersion).toBe(3);
});

test("requires is true", () => {
expect(lockfile.requires).toBe(true);
});

test("name is dbpaw", () => {
expect(lockfile.name).toBe("dbpaw");
});

test("both tauri plugin constraints are more specific than their previous tilde ranges", () => {
// ~2 would allow 2.x.x; ^2.3.1 pins to >=2.3.1 <3.0.0 and is more specific
const deps = lockfile.packages[""].dependencies;
const processConstraint = deps["@tauri-apps/plugin-process"];
const updaterConstraint = deps["@tauri-apps/plugin-updater"];

// Verify they are not loose tilde-2 constraints
expect(processConstraint).not.toBe("~2");

Check failure on line 109 in src/lockfile.unit.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).not.toBe(expected)

Expected: not "~2" at <anonymous> (/home/runner/work/dbpaw/dbpaw/src/lockfile.unit.test.ts:109:37)
expect(updaterConstraint).not.toBe("~2");

// Verify they contain explicit patch version info
expect(processConstraint).toMatch(/\^2\.\d+\.\d+/);
expect(updaterConstraint).toMatch(/\^2\.\d+\.\d+/);
});
});
});
Loading