cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3d2fc132d5e8a5c08805fa9b1df9c63e2db466eb

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/stringifyQuery.test.ts

23lines · modeblame

8bab6894stainless-app[bot]1 years ago1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2d51afdcstainless-app[bot]2 years ago2
8bab6894stainless-app[bot]1 years ago3import { Cloudflare } from 'cloudflare';
2d51afdcstainless-app[bot]2 years ago4
8bab6894stainless-app[bot]1 years ago5const { stringifyQuery } = Cloudflare.prototype as any;
6
8765005bstainless-app[bot]1 years ago7describe(stringifyQuery, () => {
8for (const [input, expected] of [
9[{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'],
10[{ a: null, b: false, c: undefined }, 'a=&b=false'],
11[{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`],
12[
13{ 'a/b': 'c/d', 'e=f': 'g&h' },
14`${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent(
15'e=f',
16)}=${encodeURIComponent('g&h')}`,
17],
18]) {
19it(`${JSON.stringify(input)} -> ${expected}`, () => {
20expect(stringifyQuery(input)).toEqual(expected);
21});
22}
23});