From 9e5710d534fa27cb43b2bb43186ec7cbfbe3de63 Mon Sep 17 00:00:00 2001 From: cm-ayf Date: Thu, 23 May 2024 00:57:35 +0900 Subject: [PATCH] add test for version export --- package.json | 1 + pnpm-lock.yaml | 7 +++++++ test/index.js | 40 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b6a5d67..5def8aa 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73c0ce5..94e7662 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false devDependencies: + '@iarna/toml': + specifier: ^2.2.5 + version: 2.2.5 '@napi-rs/cli': specifier: ^2.16.3 version: 2.16.3 @@ -24,6 +27,10 @@ packages: resolution: {integrity: sha512-WxXiHFmD9u/owrzempiDlBB1ZYqiLnm9s6aPc8AlFQalq2tKmqdmMr9GXOupDgzXtqnBipj8Un0gkIm7Sjf8mw==} dev: true + /@iarna/toml@2.2.5: + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} + dev: true + /@napi-rs/cli@2.16.3: resolution: {integrity: sha512-3mLNPlbbOhpbIUKicLrJtIearlHXUuXL3UeueYyRRplpVMNkdn8xCyzY6PcYZi3JXR8bmCOiWgkVmLnrSL7DKw==} engines: {node: '>= 10'} diff --git a/test/index.js b/test/index.js index 34775af..49d093a 100644 --- a/test/index.js +++ b/test/index.js @@ -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); + }); +}); /** *