forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nock.d.ts
105 lines (79 loc) · 3.19 KB
/
nock.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Type definitions for nock v0.54.0
// Project: https://github.com/pgte/nock
// Definitions by: bonnici <https://github.com/bonnici>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/nock.d.ts
declare module "nock" {
export = nock;
function nock (host: string, options?: nock.Options): nock.Scope;
module nock {
export function cleanAll(): void;
export function disableNetConnect(): void;
export function enableNetConnect(): void;
export function enableNetConnect(regex: RegExp): void;
export function enableNetConnect(domain: string): void;
export var recorder: Recorder;
export interface Scope {
get(path: string, data?: string): Scope;
post(path: string, data?: string): Scope;
post(path: string, data?: Object): Scope;
post(path: string, regex?: RegExp): Scope;
patch(path: string, data?: string): Scope;
patch(path: string, data?: Object): Scope;
patch(path: string, regex?: RegExp): Scope;
put(path: string, data?: string): Scope;
put(path: string, data?: Object): Scope;
put(path: string, regex?: RegExp): Scope;
head(path: string): Scope;
delete(path: string, data?: string): Scope;
delete(path: string, data?: Object): Scope;
delete(path: string, regex?: RegExp): Scope;
merge(path: string, data?: string): Scope;
merge(path: string, data?: Object): Scope;
merge(path: string, regex?: RegExp): Scope;
query(params: any): Scope;
query(acceptAnyParams: boolean): Scope;
intercept(path: string, verb: string, body?: string, options?: any): Scope;
intercept(path: string, verb: string, body?: Object, options?: any): Scope;
intercept(path: string, verb: string, body?: RegExp, options?: any): Scope;
reply(responseCode: number, body?: string, headers?: Object): Scope;
reply(responseCode: number, body?: Object, headers?: Object): Scope;
reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope;
replyWithFile(responseCode: number, fileName: string): Scope;
replyWithError(errorMessage: string): Scope;
defaultReplyHeaders(headers: Object): Scope;
matchHeader(name: string, value: string): Scope;
matchHeader(name: string, regex: RegExp): Scope;
matchHeader(name: string, fn: (value: string) => boolean): Scope;
filteringPath(regex: RegExp, replace: string): Scope;
filteringPath(fn: (path: string) => string): Scope;
filteringRequestBody(regex: RegExp, replace: string): Scope;
filteringRequestBody(fn: (path: string) => string): Scope;
persist(): Scope;
log(out: () => void): Scope;
delay(timeMs: number): Scope;
delayConnection(timeMs: number): Scope;
times(repeats: number): Scope;
once(): Scope;
twice(): Scope;
thrice(): Scope;
done(): void;
isDone(): boolean;
restore(): void;
pendingMocks(): Object[];
}
export interface Recorder {
rec(capture?: boolean): void;
rec(options?: RecorderOptions): void;
play(): any[];
}
export interface Options {
allowUnmocked?: boolean;
}
export interface RecorderOptions {
dont_print?: boolean;
output_objects?: boolean;
enable_reqheaders_recording?: boolean;
}
}
}