From 7b2e73d14bdad5e93c99dec891ded50149a7ed52 Mon Sep 17 00:00:00 2001 From: isaac hershenson Date: Wed, 11 Dec 2024 10:35:21 -0800 Subject: [PATCH] fmt --- js/src/tests/client.int.test.ts | 20 +++--- js/src/tests/evaluate_attachments.int.test.ts | 63 +++++++++---------- 2 files changed, 36 insertions(+), 47 deletions(-) diff --git a/js/src/tests/client.int.test.ts b/js/src/tests/client.int.test.ts index 7c4f58b9b..de8710e1f 100644 --- a/js/src/tests/client.int.test.ts +++ b/js/src/tests/client.int.test.ts @@ -1425,9 +1425,9 @@ test("update examples multipart", async () => { expect(attachmentData).toEqual(new Uint8Array(fs.readFileSync(pathname))); attachmentData = updatedExample.attachments?.["bar"].presigned_url ? new Uint8Array( - (await fetch( - updatedExample.attachments?.["bar"].presigned_url - ).then((res) => res.arrayBuffer())) as ArrayBuffer + (await fetch(updatedExample.attachments?.["bar"].presigned_url).then( + (res) => res.arrayBuffer() + )) as ArrayBuffer ) : undefined; expect(attachmentData).toEqual(new Uint8Array(fs.readFileSync(pathname))); @@ -1443,11 +1443,8 @@ test("update examples multipart", async () => { await client.updateExamplesMultipart(dataset.id, [exampleUpdate4]); updatedExample = await client.readExample(exampleId); expect(updatedExample.metadata).toEqual({ foo: "bar" }); - expect(Object.keys(updatedExample.attachments ?? {})).toEqual([ - "test_file2", - ]); - attachmentData = updatedExample.attachments?.["test_file2"] - .presigned_url + expect(Object.keys(updatedExample.attachments ?? {})).toEqual(["test_file2"]); + attachmentData = updatedExample.attachments?.["test_file2"].presigned_url ? new Uint8Array( (await fetch( updatedExample.attachments?.["test_file2"].presigned_url @@ -1471,11 +1468,8 @@ test("update examples multipart", async () => { foo: "bar", dataset_split: ["foo", "bar"], }); - expect(Object.keys(updatedExample.attachments ?? {})).toEqual([ - "test_file", - ]); - attachmentData = updatedExample.attachments?.["test_file"] - .presigned_url + expect(Object.keys(updatedExample.attachments ?? {})).toEqual(["test_file"]); + attachmentData = updatedExample.attachments?.["test_file"].presigned_url ? new Uint8Array( (await fetch( updatedExample.attachments?.["test_file"].presigned_url diff --git a/js/src/tests/evaluate_attachments.int.test.ts b/js/src/tests/evaluate_attachments.int.test.ts index e1c346d91..0a64a54f9 100644 --- a/js/src/tests/evaluate_attachments.int.test.ts +++ b/js/src/tests/evaluate_attachments.int.test.ts @@ -44,9 +44,9 @@ test("evaluate can handle examples with attachments", async () => { "image" ].presigned_url ? new Uint8Array( - (await fetch( - config?.attachments?.["image"].presigned_url - ).then((res) => res.arrayBuffer())) as ArrayBuffer + (await fetch(config?.attachments?.["image"].presigned_url).then( + (res) => res.arrayBuffer() + )) as ArrayBuffer ) : undefined; if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) { @@ -61,12 +61,11 @@ test("evaluate can handle examples with attachments", async () => { const expectedData = new Uint8Array( Buffer.from("fake image data for testing") ); - const attachmentData: Uint8Array | undefined = attachments?.[ - "image" - ].presigned_url + const attachmentData: Uint8Array | undefined = attachments?.["image"] + .presigned_url ? new Uint8Array( - (await fetch(attachments?.["image"].presigned_url).then( - (res) => res.arrayBuffer() + (await fetch(attachments?.["image"].presigned_url).then((res) => + res.arrayBuffer() )) as ArrayBuffer ) : undefined; @@ -139,12 +138,11 @@ test("evaluate with attachments not in target function", async () => { const expectedData = new Uint8Array( Buffer.from("fake image data for testing") ); - const attachmentData: Uint8Array | undefined = attachments?.[ - "image" - ].presigned_url + const attachmentData: Uint8Array | undefined = attachments?.["image"] + .presigned_url ? new Uint8Array( - (await fetch(attachments?.["image"].presigned_url).then( - (res) => res.arrayBuffer() + (await fetch(attachments?.["image"].presigned_url).then((res) => + res.arrayBuffer() )) as ArrayBuffer ) : undefined; @@ -222,9 +220,9 @@ test("multiple evaluators with attachments", async () => { "image" ].presigned_url ? new Uint8Array( - (await fetch( - config?.attachments?.["image"].presigned_url - ).then((res) => res.arrayBuffer())) as ArrayBuffer + (await fetch(config?.attachments?.["image"].presigned_url).then( + (res) => res.arrayBuffer() + )) as ArrayBuffer ) : undefined; if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) { @@ -239,12 +237,11 @@ test("multiple evaluators with attachments", async () => { const expectedData = new Uint8Array( Buffer.from("fake image data for testing") ); - const attachmentData: Uint8Array | undefined = attachments?.[ - "image" - ].presigned_url + const attachmentData: Uint8Array | undefined = attachments?.["image"] + .presigned_url ? new Uint8Array( - (await fetch(attachments?.["image"].presigned_url).then( - (res) => res.arrayBuffer() + (await fetch(attachments?.["image"].presigned_url).then((res) => + res.arrayBuffer() )) as ArrayBuffer ) : undefined; @@ -263,12 +260,11 @@ test("multiple evaluators with attachments", async () => { const expectedData = new Uint8Array( Buffer.from("fake image data for testing") ); - const attachmentData: Uint8Array | undefined = attachments?.[ - "image" - ].presigned_url + const attachmentData: Uint8Array | undefined = attachments?.["image"] + .presigned_url ? new Uint8Array( - (await fetch(attachments?.["image"].presigned_url).then( - (res) => res.arrayBuffer() + (await fetch(attachments?.["image"].presigned_url).then((res) => + res.arrayBuffer() )) as ArrayBuffer ) : undefined; @@ -343,9 +339,9 @@ test("evaluate with attachments runnable target function", async () => { "image" ].presigned_url ? new Uint8Array( - (await fetch( - config?.attachments?.["image"].presigned_url - ).then((res) => res.arrayBuffer())) as ArrayBuffer + (await fetch(config?.attachments?.["image"].presigned_url).then( + (res) => res.arrayBuffer() + )) as ArrayBuffer ) : undefined; if (!arraysEqual(attachmentData ?? new Uint8Array(), expectedData)) { @@ -363,12 +359,11 @@ test("evaluate with attachments runnable target function", async () => { const expectedData = new Uint8Array( Buffer.from("fake image data for testing") ); - const attachmentData: Uint8Array | undefined = attachments?.[ - "image" - ].presigned_url + const attachmentData: Uint8Array | undefined = attachments?.["image"] + .presigned_url ? new Uint8Array( - (await fetch(attachments?.["image"].presigned_url).then( - (res) => res.arrayBuffer() + (await fetch(attachments?.["image"].presigned_url).then((res) => + res.arrayBuffer() )) as ArrayBuffer ) : undefined;