diff --git a/index.d.ts b/index.d.ts index 9165925..2fb217f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,13 @@ import { Application, Context } from 'egg'; import { MockMate } from 'mm'; +import { Test } from 'supertest'; + +interface EggTest extends Test { + unexpectHeader(name: string, b?: Function): EggTest; + expectHeader(name: string, b?: Function): EggTest; +} + +type Methods = 'get' | 'post' | 'delete' | 'del' | 'put' | 'head' | 'options' | 'patch' | 'trace' | 'connect'; export interface BaseMockApplication extends Application { // tslint:disble-line ready(): Promise; @@ -42,7 +50,11 @@ export interface BaseMockApplication extends Application { // tslint:disbl /** * http request helper */ - httpRequest(): any; + httpRequest(): { + [key in Methods]: (url: string) => EggTest; + } & { + [key: string]: (url: string) => EggTest; + }; } interface ResultObject { diff --git a/package.json b/package.json index 94840ef..b0a6ec2 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "dependencies": { "@types/power-assert": "^1.5.0", + "@types/supertest": "^2.0.7", "await-event": "^2.1.0", "co": "^4.6.0", "coffee": "^5.2.1", @@ -41,9 +42,9 @@ "merge-descriptors": "^1.0.1", "methods": "^1.1.2", "mm": "^2.5.0", + "mz-modules": "^2.1.0", "power-assert": "^1.6.1", "supertest": "^4.0.2", - "mz-modules": "^2.1.0", "urllib": "^2.33.3" }, "devDependencies": {