2024-06-25 15:59:55 +00:00
|
|
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
2023-07-20 15:19:39 -07:00
|
|
|
|
2026-02-26 16:05:12 +00:00
|
|
|
import { stringifyQuery } from 'openai/internal/utils/query';
|
2024-06-25 15:59:55 +00:00
|
|
|
|
|
|
|
|
describe(stringifyQuery, () => {
|
2023-07-20 15:19:39 -07:00
|
|
|
for (const [input, expected] of [
|
|
|
|
|
[{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'],
|
|
|
|
|
[{ a: null, b: false, c: undefined }, 'a=&b=false'],
|
|
|
|
|
[{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`],
|
|
|
|
|
[
|
|
|
|
|
{ 'a/b': 'c/d', 'e=f': 'g&h' },
|
|
|
|
|
`${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent(
|
|
|
|
|
'e=f',
|
|
|
|
|
)}=${encodeURIComponent('g&h')}`,
|
|
|
|
|
],
|
2026-02-26 16:05:12 +00:00
|
|
|
] as const) {
|
2023-07-20 15:19:39 -07:00
|
|
|
it(`${JSON.stringify(input)} -> ${expected}`, () => {
|
|
|
|
|
expect(stringifyQuery(input)).toEqual(expected);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|