forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jasmine-ajax.d.ts
82 lines (68 loc) · 2.26 KB
/
jasmine-ajax.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
// Type definitions for jasmine-ajax 3.1.1
// Project: https://github.com/jasmine/jasmine-ajax
// Definitions by: Louis Grignon <https://github.com/lgrignon>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface JasmineAjaxResponse {
status?: number;
statusText?: string;
responseText?: string;
response?: string;
contentType?: string;
responseHeaders?: { [key: string]: string };
}
interface JasmineAjaxRequest extends XMLHttpRequest {
url: string;
method: string;
username: string;
password: string;
requestHeaders: { [key: string]: string };
overriddenMimeType: string;
respondWith(response: JasmineAjaxResponse): void;
}
interface JasmineAjaxRequestTracker {
track(request: JasmineAjaxRequest): void;
first(): JasmineAjaxRequest;
count(): number;
reset(): void;
mostRecent(): JasmineAjaxRequest;
at(index: number): JasmineAjaxRequest;
filter(urlToMatch: RegExp): JasmineAjaxRequest[];
filter(urlToMatch: Function): JasmineAjaxRequest[];
filter(urlToMatch: string): JasmineAjaxRequest[];
}
interface JasmineAjaxRequestStubReturnOptions {
status?: number;
contentType?: string;
response?: string;
responseText?: string;
responseHeaders?: { [key: string]: string };
}
interface JasmineAjaxRequestStub {
data?: string;
method?: string;
andReturn(options: JasmineAjaxRequestStubReturnOptions): void;
matches(fullUrl: string, data: string, method: string): boolean;
}
interface JasmineAjaxStubTracker {
addStub(stub: JasmineAjaxRequestStub): void;
reset(): void;
findStub(url: string, data?: string, method?: string): JasmineAjaxRequestStub;
}
interface JasmineAjaxParamParser {
test(xhr: XMLHttpRequest): boolean;
parse(paramString: string): any;
}
declare class MockAjax {
constructor(globals: any);
install(): void;
uninstall(): void;
withMock(closure: () => void): void;
addCustomParamParser(parser: JasmineAjaxParamParser): void;
stubRequest(url: RegExp, data?: string, method?: string): JasmineAjaxRequestStub;
stubRequest(url: string, data?: string, method?: string): JasmineAjaxRequestStub;
requests: JasmineAjaxRequestTracker;
stubs: JasmineAjaxStubTracker;
}
declare module jasmine {
export var Ajax: MockAjax;
}