Skip to content

Commit

Permalink
fix: fix httpRequest function signature (#105)
Browse files Browse the repository at this point in the history
* fix: fix httpRequest function signature

* refactor: for better intelligence
  • Loading branch information
zbinlin authored and whxaxes committed Jun 24, 2019
1 parent 272e797 commit d836536
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -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<T, C> extends Application { // tslint:disble-line
ready(): Promise<void>;
Expand Down Expand Up @@ -42,7 +50,11 @@ export interface BaseMockApplication<T, C> extends Application { // tslint:disbl
/**
* http request helper
*/
httpRequest(): any;
httpRequest(): {
[key in Methods]: (url: string) => EggTest;
} & {
[key: string]: (url: string) => EggTest;
};
}

interface ResultObject {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down

0 comments on commit d836536

Please sign in to comment.