/** * @file API Test * @author Yourtion Guo */ import type { SuperTest, Test } from "supertest"; import type ERest from ".."; import { TestAgent } from "../agent"; import { type ISupportMethds } from "../utils"; /** 测试Agent */ export type IAgent = Readonly TestAgent>>; export interface ITestSession extends IAgent { /** 原始SuperTestAgent */ readonly $agent: SuperTest; } export default class IAPITest { private erest; private info; private app; private testPath; private supertest?; constructor(erestIns: ERest, path: string); get get(): (path: string) => TestAgent; get post(): (path: string) => TestAgent; get put(): (path: string) => TestAgent; get delete(): (path: string) => TestAgent; get patch(): (path: string) => TestAgent; /** 创建测试会话 */ session(): ITestSession; /** 根据请求方法和请求路径查找对应的API */ private findApi; /** 生成测试方法 */ private buildTest; }