From c4ebf7b572117a1d0251471cb6d84f8aa813ae15 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> Date: Wed, 12 Mar 2025 12:59:16 +0100 Subject: [PATCH] Delete frontend/src/__tests__/public/validate-json.test.ts --- .../__tests__/public/validate-json.test.ts | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 frontend/src/__tests__/public/validate-json.test.ts diff --git a/frontend/src/__tests__/public/validate-json.test.ts b/frontend/src/__tests__/public/validate-json.test.ts deleted file mode 100644 index 562ebe9..0000000 --- a/frontend/src/__tests__/public/validate-json.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { describe, it, assert, beforeAll } from "vitest"; -import { promises as fs } from "fs"; -import path from "path"; -import { ScriptSchema, type Script } from "@/app/json-editor/_schemas/schemas"; -import { Metadata } from "@/lib/types"; - -const jsonDir = "public/json"; -const metadataFileName = "metadata.json"; -const encoding = "utf-8"; - -const fileNames = (await fs.readdir(jsonDir)) - .filter((fileName) => fileName !== metadataFileName) - -describe.each(fileNames)("%s", async (fileName) => { - let script: Script; - - beforeAll(async () => { - const filePath = path.resolve(jsonDir, fileName); - const fileContent = await fs.readFile(filePath, encoding) - script = JSON.parse(fileContent); - }) - - it("should have valid json according to script schema", () => { - ScriptSchema.parse(script); - }); - - it("should have a corresponding script file", () => { - script.install_methods.forEach((method) => { - const scriptPath = path.resolve("..", method.script) - assert(fs.stat(scriptPath), `Script file not found: ${scriptPath}`) - }) - }); -}) - -describe(`${metadataFileName}`, async () => { - let metadata: Metadata; - - beforeAll(async () => { - const filePath = path.resolve(jsonDir, metadataFileName); - const fileContent = await fs.readFile(filePath, encoding) - metadata = JSON.parse(fileContent); - }) - - it("should have valid json according to metadata schema", () => { - // TODO: create zod schema for metadata. Move zod schemas to /lib/types.ts - assert(metadata.categories.length > 0); - metadata.categories.forEach((category) => { - assert.isString(category.name) - assert.isNumber(category.id) - assert.isNumber(category.sort_order) - }); - }); -})