refactor: 리펙토링
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { assertMatchesJsonSchema } from "../../scripts/lib/json-schema.ts";
|
||||
|
||||
async function json(path: string): Promise<unknown> {
|
||||
return JSON.parse(await readFile(path, "utf8")) as unknown;
|
||||
}
|
||||
|
||||
describe("checked-in JSON Schema execution", () => {
|
||||
it("accepts a build manifest and rejects undeclared output fields", async () => {
|
||||
const schema = await json("schemas/artifacts/build-manifest.schema.json");
|
||||
const manifest = {
|
||||
schemaVersion: 1,
|
||||
buildId: "build-1",
|
||||
commitSha: "commit-1",
|
||||
releaseId: "release-1",
|
||||
moduleInventoryHash: "inventory-hash",
|
||||
generatedAt: "2026-08-01T00:00:00.000Z",
|
||||
buildContext: {
|
||||
nodeVersion: "v24.11.0",
|
||||
packageManagerVersion: "11.17.0",
|
||||
runnerImage: "test-runner",
|
||||
sourceDateEpoch: null,
|
||||
},
|
||||
outputs: {
|
||||
directory: "dist",
|
||||
viteManifest: "dist/.vite/manifest.json",
|
||||
moduleInventory: "artifacts/quality/vite-module-inventory.json",
|
||||
routeChunks: { home: "assets/home.js" },
|
||||
runtimeConfigSchema: "dist/runtime-config.schema.json",
|
||||
},
|
||||
};
|
||||
|
||||
expect(() =>
|
||||
assertMatchesJsonSchema(schema, manifest, "build manifest"),
|
||||
).not.toThrow();
|
||||
expect(() =>
|
||||
assertMatchesJsonSchema(
|
||||
schema,
|
||||
{ ...manifest, undocumented: true },
|
||||
"build manifest",
|
||||
),
|
||||
).toThrow(/checked-in JSON Schema/u);
|
||||
});
|
||||
|
||||
it("resolves local schema definitions in the recipe catalog", async () => {
|
||||
const [schema, catalog] = await Promise.all([
|
||||
json("schemas/config/frontend-capability-recipes.schema.json"),
|
||||
json("config/recipes/frontend-capability-recipes.json"),
|
||||
]);
|
||||
|
||||
expect(() =>
|
||||
assertMatchesJsonSchema(schema, catalog, "optional recipe catalog"),
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user