diff options
| author | adamdotdevin <[email protected]> | 2025-07-22 11:50:51 -0500 |
|---|---|---|
| committer | adamdotdevin <[email protected]> | 2025-07-22 11:50:51 -0500 |
| commit | 10c8b495907069461f5dc464f6285321290c8b14 (patch) | |
| tree | 9fed07910dd7d99688c0261a364d810a500e21d3 /packages/sdk/tests/stringifyQuery.test.ts | |
| parent | 500cea5ce7fa635a924cd9abea63aaf672f7645d (diff) | |
| download | opencode-10c8b495907069461f5dc464f6285321290c8b14.tar.gz opencode-10c8b495907069461f5dc464f6285321290c8b14.zip | |
chore: generate sdk into packages/sdk
Diffstat (limited to 'packages/sdk/tests/stringifyQuery.test.ts')
| -rw-r--r-- | packages/sdk/tests/stringifyQuery.test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/sdk/tests/stringifyQuery.test.ts b/packages/sdk/tests/stringifyQuery.test.ts new file mode 100644 index 000000000..a028772d4 --- /dev/null +++ b/packages/sdk/tests/stringifyQuery.test.ts @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { Opencode } from '@opencode-ai/sdk'; + +const { stringifyQuery } = Opencode.prototype as any; + +describe(stringifyQuery, () => { + 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')}`, + ], + ]) { + it(`${JSON.stringify(input)} -> ${expected}`, () => { + expect(stringifyQuery(input)).toEqual(expected); + }); + } + + for (const value of [[], {}, new Date()]) { + it(`${JSON.stringify(value)} -> <error>`, () => { + expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`); + }); + } +}); |
