Files
directus/api/src/utils/validate-query.test.ts
Rijk van Zanten c48309ab68 Last eslint tweak (#18198)
* Should be there now

* Format
2023-04-14 17:40:50 -04:00

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');
});
});