2
0
mirror of https://github.com/iconify/iconify.git synced 2024-11-10 07:11:00 +00:00
iconify/packages/core/tests/30-api/10-merge-params-test.ts
2021-09-01 11:34:58 +03:00

35 lines
699 B
TypeScript

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