Files
vercel/packages/cli/test/unit/util/dev/parse-query-string.test.ts
Ethan Arrowood 253b4fd1d2 [cli][client][error-utils][frameworks][fs-detectors][hydrogen][next][node-bridge][node][redwood][remix][routing-utils][static-config] update @types/node to v14 across repo (#8842)
### Related Issues

Updates @types/node to the latest version within the v14 major (based on `npm view @types/node`)

```
❯ npm view @types/node@'>=14.0.0 <15.0.0' version | tail -1
@types/node@14.18.33 '14.18.33'
```

This PR also fixes the various necessary type changes

### 📋 Checklist

<!--
  Please keep your PR as a Draft until the checklist is complete
-->

#### Tests

- [ ] The code changed/added as part of this PR has been covered with tests
- [ ] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
2022-11-04 20:21:13 +00:00

47 lines
1.5 KiB
TypeScript

import {
parseQueryString,
formatQueryString,
} from '../../../../src/util/dev/parse-query-string';
describe('parseQueryString', () => {
it('should parse to Map and format back to original String', async () => {
const querystring =
'?a&a=&a&b=1&c=2&c=3&d=&d&d=&space%20bar=4&html=%3Ch1%3E';
const parsed = parseQueryString(querystring);
expect(parsed).toEqual({
a: [undefined, '', undefined],
b: ['1'],
c: ['2', '3'],
d: ['', undefined, ''],
'space bar': ['4'],
html: ['<h1>'],
});
const format = formatQueryString(parsed);
expect(format).toEqual(querystring);
});
it('should work with empty string', async () => {
const parsed = parseQueryString('');
expect(parsed).toEqual({});
const format = formatQueryString(parsed);
expect(format).toEqual(null);
});
it('should work with question mark', async () => {
const parsed = parseQueryString('?');
expect(parsed).toEqual({});
const format = formatQueryString(parsed);
expect(format).toEqual(null);
});
it('should work without question mark', async () => {
const parsed = parseQueryString('blarg');
expect(parsed).toEqual({});
const format = formatQueryString(parsed);
expect(format).toEqual(null);
});
it('should work with undefined', async () => {
const parsed = parseQueryString(undefined);
expect(parsed).toEqual({});
const format = formatQueryString(parsed);
expect(format).toEqual(null);
});
});