Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.2 KiB
Text
37 lines
1.2 KiB
Text
import { TypeCompiler } from '@sinclair/typebox/compiler';
|
|
import { typeboxResolver } from '..';
|
|
import { fields, invalidData, schema, validData } from './__fixtures__/data';
|
|
|
|
const shouldUseNativeValidation = false;
|
|
|
|
describe('typeboxResolver (with compiler)', () => {
|
|
const typecheck = TypeCompiler.Compile(schema);
|
|
|
|
it('should return a single error from typeboxResolver when validation fails', async () => {
|
|
const result = await typeboxResolver(typecheck)(invalidData, undefined, {
|
|
fields,
|
|
shouldUseNativeValidation,
|
|
});
|
|
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
|
|
it('should return all the errors from typeboxResolver when validation fails with `validateAllFieldCriteria` set to true', async () => {
|
|
const result = await typeboxResolver(typecheck)(invalidData, undefined, {
|
|
fields,
|
|
criteriaMode: 'all',
|
|
shouldUseNativeValidation,
|
|
});
|
|
|
|
expect(result).toMatchSnapshot();
|
|
});
|
|
|
|
it('should validate with success', async () => {
|
|
const result = await typeboxResolver(typecheck)(validData, undefined, {
|
|
fields,
|
|
shouldUseNativeValidation,
|
|
});
|
|
|
|
expect(result).toEqual({ errors: {}, values: validData });
|
|
});
|
|
});
|