Skip to content

Commit 0341ff6

Browse files
RobertCraigiestainless-app[bot]
authored andcommitted
chore(internal): add ecosystem test for qs reproduction
1 parent 40e8284 commit 0341ff6

File tree

6 files changed

+2168
-0
lines changed

6 files changed

+2168
-0
lines changed

ecosystem-tests/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ const projectRunners = {
3434
await installPackage();
3535
await run('node', ['test.js']);
3636
},
37+
'nodenext-tsup': async () => {
38+
await installPackage();
39+
await run('npm', ['run', 'build']);
40+
41+
if (state.live) {
42+
await run('npm', ['run', 'main']);
43+
}
44+
},
3745
'ts-browser-webpack': async () => {
3846
await installPackage();
3947

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { OpenAI } from 'openai';
2+
3+
const openai = new OpenAI();
4+
5+
function assertEqual(actual: any, expected: any) {
6+
if (actual === expected) {
7+
return;
8+
}
9+
10+
console.error('expected', expected);
11+
console.error('actual ', actual);
12+
throw new Error('expected values to be equal');
13+
}
14+
15+
async function main() {
16+
const completion = await openai.chat.completions.create({
17+
model: 'gpt-4o-mini',
18+
messages: [
19+
{
20+
role: 'user',
21+
content: 'What is the capital of the United States?',
22+
},
23+
],
24+
});
25+
// smoke test for responses
26+
if (!completion.choices[0]?.message.content) {
27+
console.dir(completion, { depth: 4 });
28+
throw new Error('no response content!');
29+
}
30+
31+
assertEqual(
32+
decodeURIComponent((openai as any).stringifyQuery({ foo: { nested: { a: true, b: 'foo' } } })),
33+
'foo[nested][a]=true&foo[nested][b]=foo',
34+
);
35+
assertEqual(
36+
decodeURIComponent((openai as any).stringifyQuery({ foo: { nested: { a: ['hello', 'world'] } } })),
37+
'foo[nested][a][]=hello&foo[nested][a][]=world',
38+
);
39+
}
40+
41+
main();

0 commit comments

Comments
 (0)