cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
tests/stringifyQuery.test.ts
21lines · modeblame
ce6a7892stainless-app[bot]2 years ago | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2d51afdcstainless-app[bot]2 years ago | 2 | |
a6729d07stainless-app[bot]2 months ago | 3 | import { stringifyQuery } from 'cloudflare/internal/utils/query'; |
ce6a7892stainless-app[bot]2 years ago | 4 | |
| 5 | describe(stringifyQuery, () => { | |
2d51afdcstainless-app[bot]2 years ago | 6 | for (const [input, expected] of [ |
| 7 | [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], | |
| 8 | [{ a: null, b: false, c: undefined }, 'a=&b=false'], | |
| 9 | [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], | |
| 10 | [ | |
| 11 | { 'a/b': 'c/d', 'e=f': 'g&h' }, | |
| 12 | `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( | |
| 13 | 'e=f', | |
| 14 | )}=${encodeURIComponent('g&h')}`, | |
| 15 | ], | |
a6729d07stainless-app[bot]2 months ago | 16 | ] as const) { |
2d51afdcstainless-app[bot]2 years ago | 17 | it(`${JSON.stringify(input)} -> ${expected}`, () => { |
| 18 | expect(stringifyQuery(input)).toEqual(expected); | |
| 19 | }); | |
| 20 | } | |
| 21 | }); |