FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
export default function parseQueryString(qs) { throw new Error('Not implemented'); }
import parseQueryString from './file'; describe('parseQueryString', () => { test('parses basic key-value pairs', () => { expect(parseQueryString('?a=1&b=two')).toEqual({ a: '1', b: 'two' }); }); test('treats + as space and decodes percent-encoding', () => { expect(parseQueryString('q=hello+world')).toEqual({ q: 'hello world' }); expect(parseQueryString('a=%26')).toEqual({ a: '&' }); }); test('keeps the last value when keys repeat', () => { expect(parseQueryString('a=1&a=2&a=3')).toEqual({ a: '3' }); }); test('missing = means empty string value', () => { expect(parseQueryString('flag')).toEqual({ flag: '' }); expect(parseQueryString('flag&x=1')).toEqual({ flag: '', x: '1' }); }); test('ignores empty keys and empty parts', () => { expect(parseQueryString('=x&&y=1&')).toEqual({ y: '1' }); }); test('does not break on malformed encoding (keeps raw)', () => { expect(parseQueryString('a=%E0%A4')).toEqual({ a: '%E0%A4' }); }); test('empty input returns {}', () => { expect(parseQueryString('')).toEqual({}); expect(parseQueryString('?')).toEqual({}); }); });
▶ Run tests
Results
Console
Run tests to see results.