mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
27 lines
724 B
TypeScript
27 lines
724 B
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import { validateQuery } from './validate-query.js';
|
|
|
|
vi.mock('../env', async () => {
|
|
const actual = (await vi.importActual('../env')) as { default: Record<string, any> };
|
|
|
|
const MOCK_ENV = {
|
|
...actual.default,
|
|
MAX_QUERY_LIMIT: 100,
|
|
};
|
|
|
|
return {
|
|
default: MOCK_ENV,
|
|
getEnv: () => MOCK_ENV,
|
|
};
|
|
});
|
|
|
|
describe('export', () => {
|
|
test.each(['csv', 'json', 'xml', 'yaml'])('should accept format %i', (format) => {
|
|
expect(() => validateQuery({ export: format } as any)).not.toThrowError();
|
|
});
|
|
|
|
test('should error with invalid-format', () => {
|
|
expect(() => validateQuery({ export: 'invalid-format' } as any)).toThrowError('"export" must be one of');
|
|
});
|
|
});
|