mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
32 lines
732 B
TypeScript
32 lines
732 B
TypeScript
import { z } from 'zod';
|
|
|
|
import { parseAnyOf } from '../../src/parsers/parse-any-of';
|
|
|
|
describe('parseAnyOf', () => {
|
|
test('should create a union from two or more schemas', () => {
|
|
expect(
|
|
parseAnyOf(
|
|
{
|
|
anyOf: [
|
|
{
|
|
type: 'string',
|
|
},
|
|
{ type: 'number' },
|
|
],
|
|
},
|
|
{ path: [], seen: new Map() },
|
|
),
|
|
).toMatchZod(z.union([z.string(), z.number()]));
|
|
});
|
|
|
|
test('should extract a single schema', () => {
|
|
expect(parseAnyOf({ anyOf: [{ type: 'string' }] }, { path: [], seen: new Map() })).toMatchZod(
|
|
z.string(),
|
|
);
|
|
});
|
|
|
|
test('should return z.any() if array is empty', () => {
|
|
expect(parseAnyOf({ anyOf: [] }, { path: [], seen: new Map() })).toMatchZod(z.any());
|
|
});
|
|
});
|