cloudflare/cloudflare-typescript

Public

mirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/stringifyQuery.test.ts

23lines · modecode

1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3import { Cloudflare } from 'cloudflare';
4
5const { stringifyQuery } = Cloudflare.prototype as any;
6
7describe(stringifyQuery, () => {
8 for (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 ]) {
19 it(`${JSON.stringify(input)} -> ${expected}`, () => {
20 expect(stringifyQuery(input)).toEqual(expected);
21 });
22 }
23});
24