url.test.ts 484 B

12345678910111213141516
  1. import { toUrlParams } from '../utils/url';
  2. describe('toUrlParams', () => {
  3. it('should encode object properties as url parameters', () => {
  4. const url = toUrlParams({
  5. server: 'backend-01',
  6. hasSpace: 'has space',
  7. many: ['1', '2', '3'],
  8. true: true,
  9. number: 20,
  10. isNull: null,
  11. isUndefined: undefined,
  12. });
  13. expect(url).toBe('server=backend-01&hasSpace=has%20space&many=1&many=2&many=3&true&number=20&isNull=&isUndefined=');
  14. });
  15. });