Skip to content

Commit 93d9b5b

Browse files
stainless-emRobertCraigie
authored andcommitted
chore(internal): fix tests
1 parent c5e49c1 commit 93d9b5b

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"eslint": "^8.49.0",
3636
"eslint-plugin-prettier": "^5.0.1",
3737
"eslint-plugin-unused-imports": "^3.0.0",
38+
"execa": "^5.1.1",
3839
"fast-check": "^3.22.0",
3940
"iconv-lite": "^0.6.3",
4041
"jest": "^29.4.0",

tests/lib/azure.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ describe('azure request building', () => {
376376
expect(
377377
await client.audio.translations.create({
378378
model,
379-
file: { url: 'https://example.com', blob: () => 0 as any },
379+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
380380
}),
381381
).toMatchObject({
382382
url: `https://example.com/openai/deployments/${deployment}/audio/translations?api-version=${apiVersion}`,
@@ -387,7 +387,7 @@ describe('azure request building', () => {
387387
expect(
388388
await client.audio.transcriptions.create({
389389
model,
390-
file: { url: 'https://example.com', blob: () => 0 as any },
390+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
391391
}),
392392
).toMatchObject({
393393
url: `https://example.com/openai/deployments/${deployment}/audio/transcriptions?api-version=${apiVersion}`,
@@ -432,7 +432,7 @@ describe('azure request building', () => {
432432
test('handles files', async () => {
433433
expect(
434434
await client.files.create({
435-
file: { url: 'https://example.com', blob: () => 0 as any },
435+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
436436
purpose: 'assistants',
437437
}),
438438
).toMatchObject({
@@ -509,7 +509,7 @@ describe('azure request building', () => {
509509
expect(
510510
await client.audio.translations.create({
511511
model: deployment,
512-
file: { url: 'https://example.com', blob: () => 0 as any },
512+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
513513
}),
514514
).toMatchObject({
515515
url: `https://example.com/openai/audio/translations?api-version=${apiVersion}`,
@@ -520,7 +520,7 @@ describe('azure request building', () => {
520520
expect(
521521
await client.audio.transcriptions.create({
522522
model: deployment,
523-
file: { url: 'https://example.com', blob: () => 0 as any },
523+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
524524
}),
525525
).toMatchObject({
526526
url: `https://example.com/openai/audio/transcriptions?api-version=${apiVersion}`,
@@ -565,7 +565,7 @@ describe('azure request building', () => {
565565
test('handles files', async () => {
566566
expect(
567567
await client.files.create({
568-
file: { url: 'https://example.com', blob: () => 0 as any },
568+
file: { url: 'https://example.com', blob: async () => new Blob([]) },
569569
purpose: 'assistants',
570570
}),
571571
).toMatchObject({

tests/responses.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { APIPromise } from 'openai/api-promise';
22
import OpenAI from 'openai/index';
33
import { compareType } from './utils/typing';
44

5+
const client = new OpenAI();
6+
57
describe('request id', () => {
68
test('types', () => {
79
compareType<Awaited<APIPromise<string>>, string>(true);
@@ -54,6 +56,7 @@ describe('request id', () => {
5456

5557
test('envelope response', async () => {
5658
const promise = new APIPromise<{ data: { foo: string } }>(
59+
client,
5760
(async () => {
5861
return {
5962
response: new Response(JSON.stringify({ data: { foo: 'bar' } }), {
@@ -86,6 +89,7 @@ describe('request id', () => {
8689

8790
test('array response', async () => {
8891
const promise = new APIPromise<Array<{ foo: string }>>(
92+
client,
8993
(async () => {
9094
return {
9195
response: new Response(JSON.stringify([{ foo: 'bar' }]), {
@@ -105,6 +109,7 @@ describe('request id', () => {
105109

106110
test('string response', async () => {
107111
const promise = new APIPromise<string>(
112+
client,
108113
(async () => {
109114
return {
110115
response: new Response('hello world', {

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ esutils@^2.0.2:
16941694
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
16951695
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
16961696

1697-
execa@^5.0.0:
1697+
execa@^5.0.0, execa@^5.1.1:
16981698
version "5.1.1"
16991699
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
17001700
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==

0 commit comments

Comments
 (0)