1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import * as superagent from 'superagent';
|
9 |
|
10 | export = supertest;
|
11 |
|
12 | declare function supertest(app: any): supertest.SuperTest<supertest.Test>;
|
13 | declare namespace supertest {
|
14 | interface Response extends superagent.Response {}
|
15 |
|
16 | interface Request extends superagent.SuperAgentRequest {}
|
17 |
|
18 | type CallbackHandler = (err: any, res: Response) => void;
|
19 | interface Test extends superagent.SuperAgentRequest {
|
20 | app?: any;
|
21 | url: string;
|
22 | serverAddress(app: any, path: string): string;
|
23 | expect(status: number, callback?: CallbackHandler): this;
|
24 | expect(status: number, body: any, callback?: CallbackHandler): this;
|
25 | expect(checker: (res: Response) => any, callback?: CallbackHandler): this;
|
26 | expect(body: string, callback?: CallbackHandler): this;
|
27 | expect(body: RegExp, callback?: CallbackHandler): this;
|
28 | expect(body: Object, callback?: CallbackHandler): this;
|
29 | expect(field: string, val: string, callback?: CallbackHandler): this;
|
30 | expect(field: string, val: RegExp, callback?: CallbackHandler): this;
|
31 | end(callback?: CallbackHandler): this;
|
32 | }
|
33 |
|
34 | interface AgentOptions {
|
35 | ca?: any;
|
36 | }
|
37 | function agent(app?: any, options?: AgentOptions): SuperAgentTest;
|
38 |
|
39 | interface SuperTest<T extends superagent.SuperAgentRequest> extends superagent.SuperAgent<T> {}
|
40 | interface SuperTestWithHost<T extends superagent.SuperAgentRequest> extends SuperTest<T> {
|
41 | host(host: string): this;
|
42 | }
|
43 | type SuperAgentTest = SuperTestWithHost<Test> &
|
44 | Pick<
|
45 | Request,
|
46 | | 'use'
|
47 | | 'on'
|
48 | | 'set'
|
49 | | 'query'
|
50 | | 'type'
|
51 | | 'accept'
|
52 | | 'auth'
|
53 | | 'withCredentials'
|
54 | | 'retry'
|
55 | | 'ok'
|
56 | | 'redirects'
|
57 | | 'timeout'
|
58 | | 'buffer'
|
59 | | 'serialize'
|
60 | | 'parse'
|
61 | | 'ca'
|
62 | | 'key'
|
63 | | 'pfx'
|
64 | | 'cert'
|
65 | >;
|
66 | }
|