1import * as QueryParams from '../QueryParams'; 2 3it(`parses a query string`, () => { 4 const results = QueryParams.getQueryParams('https://demo.io?foo=bar&git=hub'); 5 expect(results.params).toStrictEqual({ foo: 'bar', git: 'hub' }); 6}); 7 8it(`parses an error from a query string`, () => { 9 const results = QueryParams.getQueryParams( 10 'https://demo.io?foo=bar&git=hub&errorCode=invalid_prompt' 11 ); 12 expect(results.errorCode).toBe('invalid_prompt'); 13 expect(results.params.errorCode).not.toBeDefined(); 14}); 15 16it(`builds an encoded query string`, () => { 17 const results = QueryParams.buildQueryString({ foo: 'bar', git: 'hub , ' }); 18 expect(results).toBe('foo=bar&git=hub%20%2C%20'); 19}); 20