Skip to content

Commit

Permalink
add test for version export
Browse files Browse the repository at this point in the history
  • Loading branch information
cm-ayf committed May 22, 2024
1 parent 2eff5d0 commit 9e5710d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"license": "MIT",
"devDependencies": {
"@iarna/toml": "^2.2.5",
"@napi-rs/cli": "^2.16.3",
"@types/node": ">=18",
"opus-decoder": "^0.7.6",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 39 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,46 @@ const { Readable } = require("node:stream");
const { pipeline } = require("node:stream/promises");
const { setTimeout } = require("node:timers/promises");
const crypto = require("node:crypto");
const { Syrinx, EncoderType } = require("../lib");
const {
JPREPROCESS_VERSION,
JBONSAI_VERSION,
Syrinx,
EncoderType,
} = require("../lib");
const tar = require("tar-fs");
const TOML = require("@iarna/toml");

describe("version", () => {
const lockFile = fs.readFileSync("Cargo.lock", "utf-8");
const { package } = TOML.parse(lockFile);

assert(Array.isArray(package));
assert(
package.every(
/** @returns {p is { name: string; version: string }} */
(p) =>
typeof p === "object" &&
!!p &&
"name" in p &&
typeof p.name === "string" &&
"version" in p &&
typeof p.version === "string",
),
);

const jpreprocess = package.find((p) => p.name === "jpreprocess");
assert(jpreprocess);
const jbonsai = package.find((p) => p.name === "jbonsai");
assert(jbonsai);

it("should match the version of jpreprocess", () => {
assert.strictEqual(JPREPROCESS_VERSION, jpreprocess.version);
});

it("should match the version of jbonsai", () => {
assert.strictEqual(JBONSAI_VERSION, jbonsai.version);
});
});

/**
*
Expand Down

0 comments on commit 9e5710d

Please sign in to comment.