mercury-web/src/api/schemas/schemas.test.ts

12 lines
749 B
TypeScript

import { describe, it, expect } from "vitest";
import { NetWorthSchema, AnalyzeSchema, BudgetSchema, TxnSchema, LendingSchema } from "./index";
import * as fx from "../../test/fixtures";
describe("schemas parse backend fixtures", () => {
it("networth", () => expect(() => NetWorthSchema.parse(fx.netWorth)).not.toThrow());
it("analyze", () => expect(() => AnalyzeSchema.parse(fx.analyzeMonth)).not.toThrow());
it("budget", () => expect(() => BudgetSchema.parse(fx.budget)).not.toThrow());
it("transaction", () => expect(() => TxnSchema.parse(fx.txn)).not.toThrow());
it("lending", () => expect(() => LendingSchema.parse(fx.lending)).not.toThrow());
it("rejects wrong shape", () => expect(() => NetWorthSchema.parse({})).toThrow());
});