import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { z } from 'zod'; import { registry } from './index'; describe('schema registry vs real data', () => { for (const [entry, mod] of Object.entries(registry)) { const { schema, data } = mod; for (const [locale, value] of Object.entries(data)) { it(`${entry}/${locale} passes zod validation`, () => { if (schema instanceof z.ZodArray) { assert.ok(Array.isArray(value), `${entry}/${locale} should be array`); const arr = value as unknown[]; const itemSchema = schema.element; for (let i = 0; i < arr.length; i++) { const result = itemSchema.safeParse(arr[i]); if (!result.success) { assert.fail( `${entry}/${locale}[${i}] failed:\n` + JSON.stringify(result.error.issues, null, 2), ); } } } else { const result = schema.safeParse(value); if (!result.success) { assert.fail( `${entry}/${locale} failed:\n` + JSON.stringify(result.error.issues, null, 2), ); } } }); } } });