1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/admin/cors/CorsForm.test.tsx
olav e6b72ff4a0 feat: add CORS instance settings (#1239)
* feat: add CORS instance settings

* refactor: hide the CORS page when embedProxy is false
2022-08-23 14:04:09 +02:00

24 lines
821 B
TypeScript

import {
parseInputValue,
formatInputValue,
} from 'component/admin/cors/CorsForm';
test('parseInputValue', () => {
const fn = parseInputValue;
expect(fn('')).toEqual([]);
expect(fn('a')).toEqual(['a']);
expect(fn('a\nb,,c,d,')).toEqual(['a', 'b', 'c', 'd']);
expect(fn('http://localhost:8080')).toEqual(['http://localhost:8080']);
expect(fn('https://example.com')).toEqual(['https://example.com']);
expect(fn('https://example.com/')).toEqual(['https://example.com']);
expect(fn('https://example.com/')).toEqual(['https://example.com']);
});
test('formatInputValue', () => {
const fn = formatInputValue;
expect(fn(undefined)).toEqual('');
expect(fn([])).toEqual('');
expect(fn(['a'])).toEqual('a');
expect(fn(['a', 'b', 'c', 'd'])).toEqual('a\nb\nc\nd');
});