28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import test from "node:test";
|
|
import { validateTemplatePackageManifest } from "../src/index.ts";
|
|
|
|
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
|
|
for (const key of ["acheng-campus-food", "linjing-editorial"]) {
|
|
test(`${key} declares valid admin content and asset requirements`, () => {
|
|
const manifestPath = path.join(packageRoot, `template-${key}`, "template.json");
|
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
assert.deepEqual(validateTemplatePackageManifest(manifest), []);
|
|
});
|
|
}
|
|
|
|
test("template contract rejects technical or incomplete admin declarations", () => {
|
|
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
|
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
manifest.admin.sections[0].fields[0].label = "";
|
|
manifest.assetSlots[0].help = "";
|
|
assert.deepEqual(validateTemplatePackageManifest(manifest), [
|
|
"every asset slot requires key, binding, label and help",
|
|
"every admin field requires key, binding and label",
|
|
]);
|
|
});
|