@@ -26,22 +26,22 @@ describe('instantiate client', () => {
26
26
apiKey : 'My API Key' ,
27
27
} ) ;
28
28
29
- test ( 'they are used in the request' , ( ) => {
30
- const { req } = client . buildRequest ( { path : '/foo' , method : 'post' } ) ;
29
+ test ( 'they are used in the request' , async ( ) => {
30
+ const { req } = await client . buildRequest ( { path : '/foo' , method : 'post' } ) ;
31
31
expect ( req . headers . get ( 'x-my-default-header' ) ) . toEqual ( '2' ) ;
32
32
} ) ;
33
33
34
- test ( 'can ignore `undefined` and leave the default' , ( ) => {
35
- const { req } = client . buildRequest ( {
34
+ test ( 'can ignore `undefined` and leave the default' , async ( ) => {
35
+ const { req } = await client . buildRequest ( {
36
36
path : '/foo' ,
37
37
method : 'post' ,
38
38
headers : { 'X-My-Default-Header' : undefined } ,
39
39
} ) ;
40
40
expect ( req . headers . get ( 'x-my-default-header' ) ) . toEqual ( '2' ) ;
41
41
} ) ;
42
42
43
- test ( 'can be removed with `null`' , ( ) => {
44
- const { req } = client . buildRequest ( {
43
+ test ( 'can be removed with `null`' , async ( ) => {
44
+ const { req } = await client . buildRequest ( {
45
45
path : '/foo' ,
46
46
method : 'post' ,
47
47
headers : { 'X-My-Default-Header' : null } ,
@@ -344,7 +344,7 @@ describe('instantiate client', () => {
344
344
} ) ;
345
345
346
346
describe ( 'withOptions' , ( ) => {
347
- test ( 'creates a new client with overridden options' , ( ) => {
347
+ test ( 'creates a new client with overridden options' , async ( ) => {
348
348
const client = new OpenAI ( { baseURL : 'http://localhost:5000/' , maxRetries : 3 , apiKey : 'My API Key' } ) ;
349
349
350
350
const newClient = client . withOptions ( {
@@ -365,7 +365,7 @@ describe('instantiate client', () => {
365
365
expect ( newClient . constructor ) . toBe ( client . constructor ) ;
366
366
} ) ;
367
367
368
- test ( 'inherits options from the parent client' , ( ) => {
368
+ test ( 'inherits options from the parent client' , async ( ) => {
369
369
const client = new OpenAI ( {
370
370
baseURL : 'http://localhost:5000/' ,
371
371
defaultHeaders : { 'X-Test-Header' : 'test-value' } ,
@@ -380,7 +380,7 @@ describe('instantiate client', () => {
380
380
// Test inherited options remain the same
381
381
expect ( newClient . buildURL ( '/foo' , null ) ) . toEqual ( 'http://localhost:5001/foo?test-param=test-value' ) ;
382
382
383
- const { req } = newClient . buildRequest ( { path : '/foo' , method : 'get' } ) ;
383
+ const { req } = await newClient . buildRequest ( { path : '/foo' , method : 'get' } ) ;
384
384
expect ( req . headers . get ( 'x-test-header' ) ) . toEqual ( 'test-value' ) ;
385
385
} ) ;
386
386
@@ -430,8 +430,8 @@ describe('request building', () => {
430
430
const client = new OpenAI ( { apiKey : 'My API Key' } ) ;
431
431
432
432
describe ( 'custom headers' , ( ) => {
433
- test ( 'handles undefined' , ( ) => {
434
- const { req } = client . buildRequest ( {
433
+ test ( 'handles undefined' , async ( ) => {
434
+ const { req } = await client . buildRequest ( {
435
435
path : '/foo' ,
436
436
method : 'post' ,
437
437
body : { value : 'hello' } ,
@@ -466,8 +466,8 @@ describe('default encoder', () => {
466
466
}
467
467
}
468
468
for ( const jsonValue of [ { } , [ ] , { __proto__ : null } , new Serializable ( ) , new Collection ( [ 'item' ] ) ] ) {
469
- test ( `serializes ${ util . inspect ( jsonValue ) } as json` , ( ) => {
470
- const { req } = client . buildRequest ( {
469
+ test ( `serializes ${ util . inspect ( jsonValue ) } as json` , async ( ) => {
470
+ const { req } = await client . buildRequest ( {
471
471
path : '/foo' ,
472
472
method : 'post' ,
473
473
body : jsonValue ,
@@ -490,7 +490,7 @@ describe('default encoder', () => {
490
490
asyncIterable ,
491
491
] ) {
492
492
test ( `converts ${ util . inspect ( streamValue ) } to ReadableStream` , async ( ) => {
493
- const { req } = client . buildRequest ( {
493
+ const { req } = await client . buildRequest ( {
494
494
path : '/foo' ,
495
495
method : 'post' ,
496
496
body : streamValue ,
@@ -503,7 +503,7 @@ describe('default encoder', () => {
503
503
}
504
504
505
505
test ( `can set content-type for ReadableStream` , async ( ) => {
506
- const { req } = client . buildRequest ( {
506
+ const { req } = await client . buildRequest ( {
507
507
path : '/foo' ,
508
508
method : 'post' ,
509
509
body : new Response ( 'a\nb\nc\n' ) . body ,
0 commit comments