Skip to content

Commit 1574f69

Browse files
committed
- Added superagent.d.ts and supertest.d.ts
1 parent 4fb7d25 commit 1574f69

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

superagent.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
///<reference path='node.d.ts' />
2+
3+
declare module "superagent" {
4+
import superagent = module('superagent');
5+
6+
export interface Response {
7+
text: string;
8+
header: any;
9+
type: string;
10+
statusCode: number;
11+
req: any;
12+
res: any;
13+
}
14+
15+
export class Request {
16+
auth(user: string, name: string): Request;
17+
redirects(count: number): Request;
18+
type(type: string): Request;
19+
get(url: string): Request;
20+
del(url: string): Request;
21+
head(url: string): Request;
22+
post(url: string): Request;
23+
query(object: any): Request;
24+
send(object: any): Request;
25+
set(key: string, value: any): Request;
26+
field(key: string, value: any): Request;
27+
attach(key: string, file: any): Request;
28+
end(callback: (err: Error, res: Response) => void): Request;
29+
}
30+
31+
export function(url?: string, cb?: (err: Error, res: Response) => void): Request;
32+
}

supertest.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
///<reference path='node.d.ts' />
2+
///<reference path='superagent.d.ts' />
3+
4+
declare module "supertest" {
5+
import supertest = module('supertest');
6+
import superagent = module('superagent');
7+
8+
export class TestRequest extends superagent.Request {
9+
serverAddress(app: any, path: string): TestRequest;
10+
expect(responseCode: number, cb?: (err: Error, res: superagent.Response) => void): TestRequest;
11+
expect(responseBody: string, cb?: (err: Error, res: superagent.Response) => void): TestRequest;
12+
expect(headerKey: string, headerValue: string, cb?: (err: Error, res: superagent.Response) => void): TestRequest;
13+
assert(res: any, cb?: (err: Error, res: superagent.Response) => void);
14+
}
15+
16+
export function(app: any) : TestRequest;
17+
export function(url?: string, cb?: (res: superagent.Response) => void) : TestRequest;
18+
}

0 commit comments

Comments
 (0)