25 lines
1.3 KiB
TypeScript
25 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readdirSync, readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
test("the app uses one class helper and pins the code input", () => {
|
|
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")) as {
|
|
dependencies: Record<string, string>;
|
|
};
|
|
const lock = JSON.parse(readFileSync(new URL("../package-lock.json", import.meta.url), "utf8")) as {
|
|
packages: Record<string, { version?: string; dependencies?: Record<string, string> }>;
|
|
};
|
|
const lockText = readFileSync(new URL("../package-lock.json", import.meta.url), "utf8");
|
|
assert.equal(pkg.dependencies["input-otp"], "1.5.0");
|
|
assert.equal(lock.packages[""]?.dependencies?.["input-otp"], "1.5.0");
|
|
assert.equal(Object.hasOwn(pkg.dependencies, "cn"), false);
|
|
assert.equal(lock.packages[""]?.dependencies?.cn, undefined);
|
|
assert.equal(lock.packages["node_modules/cn"], undefined);
|
|
assert.equal(lock.packages["node_modules/input-otp"]?.version, "1.5.0");
|
|
assert.equal(lockText.includes("registry.npmmirror.com"), false);
|
|
const offenders = readdirSync(new URL("../src/components/ui", import.meta.url))
|
|
.filter((name) => name.endsWith(".tsx"))
|
|
.filter((name) => readFileSync(new URL(`../src/components/ui/${name}`, import.meta.url), "utf8").includes('from "cn"'));
|
|
assert.deepEqual(offenders, []);
|
|
});
|