Initial import NDC_1C
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateNormalized } from "../src/services/schemaValidator";
|
||||
import { normalizedFixture, normalizedFixtureV2, normalizedFixtureV2_0_1, normalizedFixtureV2_0_2 } from "./fixtures";
|
||||
|
||||
describe("schemaValidator", () => {
|
||||
it("passes valid normalized payload", () => {
|
||||
const result = validateNormalized(normalizedFixture(), "v1");
|
||||
expect(result.passed).toBe(true);
|
||||
expect(result.errors).toEqual([]);
|
||||
});
|
||||
|
||||
it("fails invalid payload", () => {
|
||||
const invalid = { ...normalizedFixture(), route_hint: "unknown_route" };
|
||||
const result = validateNormalized(invalid, "v1");
|
||||
expect(result.passed).toBe(false);
|
||||
expect(result.errors.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("passes valid normalized v2 payload", () => {
|
||||
const result = validateNormalized(normalizedFixtureV2(), "v2");
|
||||
expect(result.passed).toBe(true);
|
||||
expect(result.errors).toEqual([]);
|
||||
});
|
||||
|
||||
it("fails invalid v2 payload", () => {
|
||||
const invalid = { ...normalizedFixtureV2(), schema_version: "normalized_query_v1" };
|
||||
const result = validateNormalized(invalid, "v2");
|
||||
expect(result.passed).toBe(false);
|
||||
expect(result.errors.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("passes valid normalized v2.0.1 payload", () => {
|
||||
const result = validateNormalized(normalizedFixtureV2_0_1(), "v2_0_1");
|
||||
expect(result.passed).toBe(true);
|
||||
expect(result.errors).toEqual([]);
|
||||
});
|
||||
|
||||
it("passes valid normalized v2.0.2 payload", () => {
|
||||
const result = validateNormalized(normalizedFixtureV2_0_2(), "v2_0_2");
|
||||
expect(result.passed).toBe(true);
|
||||
expect(result.errors).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user