























@@ -30,6 +30,16 @@ function mockSingleActiveSummary(overrides: Partial<typeof baseActiveAnthropicSu
3030.mockResolvedValueOnce({ inferenceProfileSummaries: [] });
3131}
323233+function expectModelFields(model: unknown, expected: Record<string, unknown>): void {
34+expect(model).toBeDefined();
35+expect(typeof model).toBe("object");
36+expect(model).not.toBeNull();
37+const actual = model as Record<string, unknown>;
38+for (const [key, value] of Object.entries(expected)) {
39+expect(actual[key]).toEqual(value);
40+}
41+}
42+3343describe("bedrock discovery", () => {
3444beforeEach(() => {
3545sendMock.mockClear();
@@ -86,7 +96,7 @@ describe("bedrock discovery", () => {
86968797const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
8898expect(models).toHaveLength(1);
89-expect(models[0]).toMatchObject({
99+expectModelFields(models[0], {
90100id: "anthropic.claude-3-7-sonnet-20250219-v1:0",
91101name: "Claude 3.7 Sonnet",
92102reasoning: false,
@@ -119,7 +129,7 @@ describe("bedrock discovery", () => {
119129config: { defaultContextWindow: 64000, defaultMaxTokens: 8192 },
120130 clientFactory,
121131});
122-expect(models[0]).toMatchObject({ contextWindow: 64000, maxTokens: 8192 });
132+expectModelFields(models[0], { contextWindow: 64000, maxTokens: 8192 });
123133});
124134125135it("keeps the conservative fallback for unknown inference profiles", async () => {
@@ -147,7 +157,7 @@ describe("bedrock discovery", () => {
147157const models = await discoverBedrockModels({ region: "ap-northeast-1", clientFactory });
148158149159expect(models).toHaveLength(1);
150-expect(models[0]).toMatchObject({
160+expectModelFields(models[0], {
151161id: "jp.example.unknown-text-v1:0",
152162contextWindow: 32000,
153163maxTokens: 4096,
@@ -179,7 +189,7 @@ describe("bedrock discovery", () => {
179189180190const models = await discoverBedrockModels({ region: "ap-northeast-1", clientFactory });
181191182-expect(models[0]).toMatchObject({
192+expectModelFields(models[0], {
183193id: "jp.anthropic.claude-sonnet-4-6-v1:0",
184194contextWindow: 1_000_000,
185195});
@@ -317,17 +327,17 @@ describe("bedrock discovery", () => {
317327const globalProfile = models.find((m) => m.id === "global.anthropic.claude-sonnet-4-6");
318328319329// Foundation model has image input.
320-expect(foundationModel).toMatchObject({ input: ["text", "image"] });
330+expectModelFields(foundationModel, { input: ["text", "image"] });
321331322332// Inference profiles inherit image input from the foundation model.
323-expect(usProfile).toMatchObject({
333+expectModelFields(usProfile, {
324334name: "US Anthropic Claude Sonnet 4.6",
325335input: ["text", "image"],
326336contextWindow: 1000000,
327337maxTokens: 4096,
328338});
329-expect(euProfile).toMatchObject({ input: ["text", "image"] });
330-expect(globalProfile).toMatchObject({ input: ["text", "image"] });
339+expectModelFields(euProfile, { input: ["text", "image"] });
340+expectModelFields(globalProfile, { input: ["text", "image"] });
331341332342// Inactive profile should not be present.
333343expect(models.find((m) => m.id === "ap.anthropic.claude-sonnet-4-6")).toBeUndefined();
@@ -424,7 +434,7 @@ describe("bedrock discovery", () => {
424434const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
425435const profile = models.find((model) => model.id === "us.my-prod-profile");
426436427-expect(profile).toMatchObject({
437+expectModelFields(profile, {
428438id: "us.my-prod-profile",
429439input: ["text", "image"],
430440contextWindow: 1000000,
@@ -456,7 +466,7 @@ describe("bedrock discovery", () => {
456466457467const models = await discoverBedrockModels({ region: "us-east-1", clientFactory });
458468459-expect(models[0]).toMatchObject({
469+expectModelFields(models[0], {
460470id: "us.my-prod-profile",
461471contextWindow: 1_000_000,
462472maxTokens: 4096,
@@ -582,14 +592,14 @@ describe("bedrock discovery", () => {
582592expect(models).toHaveLength(3);
583593584594const auProfile = models.find((m) => m.id === "au.anthropic.claude-sonnet-4-6");
585-expect(auProfile).toMatchObject({
595+expectModelFields(auProfile, {
586596id: "au.anthropic.claude-sonnet-4-6",
587597name: "AU Anthropic Claude Sonnet 4.6",
588598input: ["text", "image"],
589599});
590600591601const apacProfile = models.find((m) => m.id === "apac.anthropic.claude-sonnet-4-6");
592-expect(apacProfile).toMatchObject({
602+expectModelFields(apacProfile, {
593603id: "apac.anthropic.claude-sonnet-4-6",
594604name: "APAC Anthropic Claude Sonnet 4.6",
595605input: ["text", "image"],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。