Skip to content

Commit fca297e

Browse files
committed
test(anthropic): avoid non-null payload assertions
1 parent 33387f6 commit fca297e

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/ai/src/providers/anthropic.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ describe("Anthropic provider", () => {
280280
const result = await stream.result();
281281

282282
expect(result.stopReason).toBe("error");
283-
const userMessage = (capturedPayload as { messages: Array<Record<string, unknown>> })
284-
.messages[0]!;
283+
const [userMessage] = (capturedPayload as { messages: [Record<string, unknown>] }).messages;
285284
const imageBlock = (userMessage.content as Array<Record<string, unknown>>)[1];
286285
expect(imageBlock).toMatchObject({
287286
type: "image",
@@ -340,9 +339,10 @@ describe("Anthropic provider", () => {
340339
const result = await stream.result();
341340

342341
expect(result.stopReason).toBe("error");
343-
const userMessage = (capturedPayload as { messages: Array<Record<string, unknown>> })
344-
.messages[1]!;
345-
const toolResult = (userMessage.content as Array<Record<string, unknown>>)[0]!;
342+
const [, userMessage] = (
343+
capturedPayload as { messages: [Record<string, unknown>, Record<string, unknown>] }
344+
).messages;
345+
const [toolResult] = userMessage.content as [Record<string, unknown>];
346346
const imageBlock = (toolResult.content as Array<Record<string, unknown>>)[1];
347347
expect(imageBlock).toMatchObject({
348348
type: "image",
@@ -387,8 +387,7 @@ describe("Anthropic provider", () => {
387387
const result = await stream.result();
388388

389389
expect(result.stopReason).toBe("error");
390-
const userMessage = (capturedPayload as { messages: Array<Record<string, unknown>> })
391-
.messages[0]!;
390+
const [userMessage] = (capturedPayload as { messages: [Record<string, unknown>] }).messages;
392391
expect(userMessage.content).toMatchObject([
393392
{ type: "text", text: "look" },
394393
{ type: "text", text: "(image omitted: model does not support images)" },

0 commit comments

Comments
 (0)