forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chai-http.d.ts
84 lines (71 loc) · 2.4 KB
/
chai-http.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Type definitions for chai-http
// Project: https://github.com/chaijs/chai-http
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../chai/chai.d.ts" />
declare module Chai {
interface ChaiStatic {
request: ChaiHttpRequest;
}
interface ChaiHttpRequest {
(server: any): ChaiHttp.Agent;
agent(server: any): ChaiHttp.Agent;
addPromises(promiseConstructor: any): void;
}
interface Assertion {
status(code: number): Assertion;
header(key: string, value?: string): Assertion;
header(key: string, value?: RegExp): Assertion;
headers: Assertion;
json: Assertion;
text: Assertion;
html: Assertion;
redirect: Assertion;
redirectTo(location: string): Assertion;
param(key: string, value?: string): Assertion;
cookie(key: string, value?: string): Assertion;
}
interface TypeComparison {
ip: Assertion;
}
}
declare module ChaiHttp {
interface Promise<T> {
then<U>(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U): Promise<U>;
}
interface Response {
body: any;
type: string;
status: number;
}
interface Request extends FinishedRequest {
attach(field: string, file: string|Buffer, filename: string): Request;
set(field: string, val: string): Request;
query(params: Object): Request;
send(data: Object): Request;
auth(user: string, name: string): Request;
field(name: string, val: string): Request;
end(callback?: (err: any, res: Response) => void): FinishedRequest;
}
interface FinishedRequest {
then(success?: (res: Response) => void, failure?: (err: any) => void): FinishedRequest;
catch(failure?: (err: any) => void): FinishedRequest;
}
interface Agent {
get(url: string, callback?: (err: any, res: Response) => void): Request;
post(url: string, callback?: (err: any, res: Response) => void): Request;
put(url: string, callback?: (err: any, res: Response) => void): Request;
head(url: string, callback?: (err: any, res: Response) => void): Request;
del(url: string, callback?: (err: any, res: Response) => void): Request;
options(url: string, callback?: (err: any, res: Response) => void): Request;
patch(url: string, callback?: (err: any, res: Response) => void): Request;
}
interface TypeComparison {
ip: any;
}
}
declare module "chai-http" {
function chaiHttp(chai: any, utils: any): void;
export = chaiHttp;
}