|
1 | | -import { toCamelCase, toSnakeCase } from './utils'; |
| 1 | +import { getUrlParameters, toCamelCase, toSnakeCase } from './utils'; |
2 | 2 |
|
3 | 3 | describe('utils', () => { |
4 | 4 | describe('toCamelCase', () => { |
@@ -57,3 +57,32 @@ describe('utils', () => { |
57 | 57 | }); |
58 | 58 | }); |
59 | 59 | }); |
| 60 | + |
| 61 | +describe('getUrlParameters', () => { |
| 62 | + it('should return null for a null URL', () => { |
| 63 | + const result = getUrlParameters(null); |
| 64 | + expect(result).toBeNull(); |
| 65 | + }); |
| 66 | + |
| 67 | + it('should return an empty object for a URL with no parameters', () => { |
| 68 | + const result = getUrlParameters('https://example.com'); |
| 69 | + expect(result).toEqual({}); |
| 70 | + }); |
| 71 | + |
| 72 | + it('should return an object with a single key-value pair for a URL with one parameter', () => { |
| 73 | + const result = getUrlParameters('https://example.com?name=John'); |
| 74 | + expect(result).toEqual({ name: 'John' }); |
| 75 | + }); |
| 76 | + |
| 77 | + it('should return an object with multiple key-value pairs for a URL with multiple parameters', () => { |
| 78 | + const result = getUrlParameters('https://example.com?name=John&age=30'); |
| 79 | + expect(result).toEqual({ name: 'John', age: '30' }); |
| 80 | + }); |
| 81 | + |
| 82 | + it('should handle special characters in the URL parameters', () => { |
| 83 | + const result = getUrlParameters( |
| 84 | + 'https://example.com?name=John%20Doe&city=New%20York' |
| 85 | + ); |
| 86 | + expect(result).toEqual({ name: 'John Doe', city: 'New York' }); |
| 87 | + }); |
| 88 | +}); |
0 commit comments