2
0
mirror of https://github.com/iconify/iconify.git synced 2024-10-23 17:12:03 +00:00
iconify/packages/core/tests/api/merge-params-test.ts

33 lines
624 B
TypeScript
Raw Normal View History

import { mergeParams } from '../../lib/api/params';
describe('Testing mergeParams', () => {
it('mergeParams()', () => {
// Nothing
expect(mergeParams('/foo', {})).toBe('/foo');
// Simple variables
expect(
mergeParams('/foo', {
foo: 1,
bar: 'baz',
baz: true,
})
).toBe('/foo?foo=1&bar=baz&baz=true');
// More parameters to existing query
expect(
mergeParams('/foo?bar=baz', {
foo: false,
})
).toBe('/foo?bar=baz&foo=false');
// Escaping characters
expect(
mergeParams('/foo', {
'2&2': '1=1',
'3 z': '?3',
})
).toBe('/foo?2%262=1%3D1&3%20z=%3F3');
});
});