1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export = nock;
|
9 |
|
10 | declare function nock(host: string, options?: nock.Options): nock.Scope;
|
11 |
|
12 | declare namespace nock {
|
13 | export function cleanAll(): void;
|
14 |
|
15 | export function disableNetConnect(): void;
|
16 | export function enableNetConnect(): void;
|
17 | export function enableNetConnect(regex: RegExp): void;
|
18 | export function enableNetConnect(domain: string): void;
|
19 |
|
20 | export function load(path: string): Object[];
|
21 | export function restore(): void;
|
22 |
|
23 | export var recorder: Recorder;
|
24 |
|
25 | export interface Scope {
|
26 | get(path: string, data?: string): Scope;
|
27 | get(path: RegExp, data?: string): Scope;
|
28 |
|
29 | post(path: string, data?: string): Scope;
|
30 | post(path: string, data?: Object): Scope;
|
31 | post(path: string, regex?: RegExp): Scope;
|
32 | post(path: RegExp, data?: string): Scope;
|
33 | post(path: RegExp, data?: Object): Scope;
|
34 | post(path: RegExp, regex?: RegExp): Scope;
|
35 |
|
36 | patch(path: string, data?: string): Scope;
|
37 | patch(path: string, data?: Object): Scope;
|
38 | patch(path: string, regex?: RegExp): Scope;
|
39 | patch(path: RegExp, data?: string): Scope;
|
40 | patch(path: RegExp, data?: Object): Scope;
|
41 | patch(path: RegExp, regex?: RegExp): Scope;
|
42 |
|
43 | put(path: string, data?: string): Scope;
|
44 | put(path: string, data?: Object): Scope;
|
45 | put(path: string, regex?: RegExp): Scope;
|
46 | put(path: RegExp, data?: string): Scope;
|
47 | put(path: RegExp, data?: Object): Scope;
|
48 | put(path: RegExp, regex?: RegExp): Scope;
|
49 |
|
50 | head(path: string): Scope;
|
51 | head(path: RegExp): Scope;
|
52 |
|
53 | delete(path: string, data?: string): Scope;
|
54 | delete(path: string, data?: Object): Scope;
|
55 | delete(path: string, regex?: RegExp): Scope;
|
56 | delete(path: RegExp, data?: string): Scope;
|
57 | delete(path: RegExp, data?: Object): Scope;
|
58 | delete(path: RegExp, regex?: RegExp): Scope;
|
59 |
|
60 | merge(path: string, data?: string): Scope;
|
61 | merge(path: string, data?: Object): Scope;
|
62 | merge(path: string, regex?: RegExp): Scope;
|
63 | merge(path: RegExp, data?: string): Scope;
|
64 | merge(path: RegExp, data?: Object): Scope;
|
65 | merge(path: RegExp, regex?: RegExp): Scope;
|
66 |
|
67 | query(params: any): Scope;
|
68 | query(acceptAnyParams: boolean): Scope;
|
69 |
|
70 | intercept(path: string, verb: string, body?: string, options?: any): Scope;
|
71 | intercept(path: string, verb: string, body?: Object, options?: any): Scope;
|
72 | intercept(path: string, verb: string, body?: RegExp, options?: any): Scope;
|
73 | intercept(path: RegExp, verb: string, body?: string, options?: any): Scope;
|
74 | intercept(path: RegExp, verb: string, body?: Object, options?: any): Scope;
|
75 | intercept(path: RegExp, verb: string, body?: RegExp, options?: any): Scope;
|
76 |
|
77 | reply(responseCode: number, body?: string, headers?: Object): Scope;
|
78 | reply(responseCode: number, body?: Object, headers?: Object): Scope;
|
79 | reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope;
|
80 | replyWithFile(responseCode: number, fileName: string): Scope;
|
81 | replyWithError(errorMessage: string): Scope;
|
82 |
|
83 | defaultReplyHeaders(headers: Object): Scope;
|
84 |
|
85 | matchHeader(name: string, value: string): Scope;
|
86 | matchHeader(name: string, regex: RegExp): Scope;
|
87 | matchHeader(name: string, fn: (value: string) => boolean): Scope;
|
88 |
|
89 | filteringPath(regex: RegExp, replace: string): Scope;
|
90 | filteringPath(fn: (path: string) => string): Scope;
|
91 | filteringRequestBody(regex: RegExp, replace: string): Scope;
|
92 | filteringRequestBody(fn: (path: string) => string): Scope;
|
93 |
|
94 | persist(): Scope;
|
95 | log(out: () => void): Scope;
|
96 |
|
97 | delay(timeMs: number): Scope;
|
98 | delayConnection(timeMs: number): Scope;
|
99 |
|
100 | times(repeats: number): Scope;
|
101 | once(): Scope;
|
102 | twice(): Scope;
|
103 | thrice(): Scope;
|
104 |
|
105 | done(): void;
|
106 | isDone(): boolean;
|
107 | restore(): void;
|
108 | pendingMocks(): Object[];
|
109 | }
|
110 |
|
111 | export interface Recorder {
|
112 | rec(capture?: boolean): void;
|
113 | rec(options?: RecorderOptions): void;
|
114 | play(): any[];
|
115 | }
|
116 |
|
117 | export interface Options {
|
118 | allowUnmocked?: boolean;
|
119 | }
|
120 |
|
121 | export interface RecorderOptions {
|
122 | dont_print?: boolean;
|
123 | output_objects?: boolean;
|
124 | enable_reqheaders_recording?: boolean;
|
125 | }
|
126 | }
|