Skip to content

Commit 0d5eb27

Browse files
committed
兼容单测
1 parent ca90252 commit 0d5eb27

1 file changed

Lines changed: 0 additions & 57 deletions

File tree

packages/sdk-core/test/client.test.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -46,63 +46,6 @@ describe("Client with MockRequestHandler", () => {
4646
expect(lastRequest?.url).toBe("https://example.com/api/test");
4747
expect(lastRequest?.method).toBe("POST");
4848
});
49-
test("should skip response casting when using sendWithRawResponse", async () => {
50-
// Arrange
51-
const mockHandler = new MockRequestHandler();
52-
const serverData = {
53-
ServerKey: "ServerValue",
54-
List: [{ ItemKey: "ItemValue" }],
55-
};
56-
mockHandler.mock("https://example.com/api/test", {
57-
status: 200,
58-
data: serverData,
59-
});
60-
61-
const client = new Client({
62-
host: "example.com",
63-
requestHandler: mockHandler,
64-
});
65-
66-
// 创建一个带有 responseMap 的 Command
67-
const command: any = {
68-
constructor: { name: "TestCommand" },
69-
input: {},
70-
middlewareStack: {
71-
steps: {
72-
initialize: [],
73-
serialize: [],
74-
build: [],
75-
finalizeRequest: [],
76-
},
77-
},
78-
requestConfig: {
79-
method: "POST",
80-
pathname: "/api/test",
81-
params: { Action: "Test" },
82-
},
83-
responseMap: {
84-
TestResponseMeta: {
85-
ServerKey: "clientKey",
86-
},
87-
ListMapMeta: {
88-
ItemKey: "itemKey",
89-
},
90-
},
91-
};
92-
93-
// 手动添加 castMiddleware 到 client 的 middlewareStack (因为我们 mock 了 command.middlewareStack)
94-
// 但在真实 Client.ts 中,send 方法会合并 client 和 command 的 stack
95-
// 这里我们直接依赖 Client 构造函数中添加的默认中间件,包括 castMiddleware
96-
97-
// Act
98-
const result = await client.sendWithRawResponse(command);
99-
100-
// Assert
101-
// 应该返回原始 PascalCase 数据,而不是转换后的 camelCase 数据
102-
expect(result).toEqual(serverData);
103-
104-
await client.destroy();
105-
});
10649
});
10750

10851
describe("Client destroy", () => {

0 commit comments

Comments
 (0)