chore(test): fix agent type (#3819)

This commit is contained in:
Junyi 2024-03-26 14:51:40 +08:00 committed by GitHub
parent 36372c9614
commit b6ae528d80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,6 +58,12 @@ interface Resource {
[name: string]: (params?: ActionParams) => Promise<supertest.Response>;
}
interface ExtendedAgent extends SuperAgentTest {
login: (user: any) => ExtendedAgent;
loginUsingId: (userId: number) => ExtendedAgent;
resource: (name: string, resourceOf?: any) => Resource;
}
export class MockServer extends Application {
async loadAndInstall(options: any = {}) {
await this.load({ method: 'install' });
@ -96,11 +102,7 @@ export class MockServer extends Application {
await AppSupervisor.getInstance().destroy();
}
agent(): SuperAgentTest & {
login: (user: any) => SuperAgentTest;
loginUsingId: (userId: number) => SuperAgentTest;
resource: (name: string, resourceOf?: any) => Resource;
} {
agent(): ExtendedAgent {
const agent = supertest.agent(this.callback());
const prefix = this.resourcer.options.prefix;
const proxy = new Proxy(agent, {