Remove unused function plus tests

This commit is contained in:
Ola Hungerford
2025-02-28 06:26:04 -07:00
parent 82bbe58a46
commit a1eb343b79
2 changed files with 0 additions and 79 deletions

View File

@@ -1,7 +1,6 @@
import {
generateDefaultValue,
formatFieldLabel,
validateValueAgainstSchema,
} from "../schemaUtils";
import { JsonSchemaType } from "../../components/DynamicJsonForm";
@@ -111,43 +110,3 @@ describe("formatFieldLabel", () => {
expect(formatFieldLabel("")).toBe("");
});
});
describe("validateValueAgainstSchema", () => {
test("validates string type", () => {
expect(validateValueAgainstSchema("test", { type: "string" })).toBe(true);
expect(validateValueAgainstSchema(123, { type: "string" })).toBe(false);
});
test("validates number type", () => {
expect(validateValueAgainstSchema(123, { type: "number" })).toBe(true);
expect(validateValueAgainstSchema("test", { type: "number" })).toBe(false);
});
test("validates integer type", () => {
expect(validateValueAgainstSchema(123, { type: "integer" })).toBe(true);
expect(validateValueAgainstSchema("test", { type: "integer" })).toBe(false);
});
test("validates boolean type", () => {
expect(validateValueAgainstSchema(true, { type: "boolean" })).toBe(true);
expect(validateValueAgainstSchema("test", { type: "boolean" })).toBe(false);
});
test("validates array type", () => {
expect(validateValueAgainstSchema([], { type: "array" })).toBe(true);
expect(validateValueAgainstSchema({}, { type: "array" })).toBe(false);
});
test("validates object type", () => {
expect(validateValueAgainstSchema({}, { type: "object" })).toBe(true);
expect(validateValueAgainstSchema([], { type: "object" })).toBe(false);
expect(validateValueAgainstSchema("test", { type: "object" })).toBe(false);
});
test("returns true for unknown types", () => {
expect(
// @ts-expect-error Testing with invalid type
validateValueAgainstSchema("anything", { type: "unknown" }),
).toBe(true);
});
});