协议数据模拟测试

This commit is contained in:
chen wei bo
2025-08-29 16:40:14 +08:00
parent 5f51c19bc6
commit 1e7f2cf466
42 changed files with 702 additions and 90 deletions
@@ -0,0 +1,22 @@
import type { ApiResponse } from "../client/types";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import type { IChatService } from "./IChatService";
export class MockChatService implements IChatService {
private delay(ms = 160) { return new Promise<void>(r => setTimeout(r, ms)); }
// 按你们项目的 ApiResponse 结构调整这里即可
private ok<T>(data: T): ApiResponse<T> {
return ({ ok: true, data } as unknown) as ApiResponse<T>;
}
// private err<T = unknown>(message = "mock buyChat error"): ApiResponse<T> {
// return ({ ok: false, error: { message } } as unknown) as ApiResponse<T>;
// }
async reqBuyChat(_req: proto.cs.ICSBuyChatReq): Promise<ApiResponse<proto.cs.ICSBuyChatRes>> {
await this.delay();
// CSBuyChatRes 在 proto 中为空消息,这里返回 {}
const res: proto.cs.ICSBuyChatRes = {};
return this.ok(res);
}
}