microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
transitive-dependency-serialize-javascript-root

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/typings/sinon/sinon.d.ts

437lines · modeblame

db80cd4eJimmy Thomson10 years ago1// Type definitions for Sinon 1.16.0
2// Project: http://sinonjs.org/
3// Definitions by: William Sears <https://github.com/mrbigdog2u>
4// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
6declare module Sinon {
7interface Event {}
8interface Document {}
9interface SinonSpyCallApi {
10// Properties
11thisValue: any;
12args: any[];
13exception: any;
14returnValue: any;
15
16// Methods
17calledOn(obj: any): boolean;
18calledWith(...args: any[]): boolean;
19calledWithExactly(...args: any[]): boolean;
20calledWithMatch(...args: any[]): boolean;
21notCalledWith(...args: any[]): boolean;
22notCalledWithMatch(...args: any[]): boolean;
23returned(value: any): boolean;
24threw(): boolean;
25threw(type: string): boolean;
26threw(obj: any): boolean;
27callArg(pos: number): void;
28callArgOn(pos: number, obj: any, ...args: any[]): void;
29callArgWith(pos: number, ...args: any[]): void;
30callArgOnWith(pos: number, obj: any, ...args: any[]): void;
31yield(...args: any[]): void;
32yieldOn(obj: any, ...args: any[]): void;
33yieldTo(property: string, ...args: any[]): void;
34yieldToOn(property: string, obj: any, ...args: any[]): void;
35}
36
37interface SinonSpyCall extends SinonSpyCallApi {
38calledBefore(call: SinonSpyCall): boolean;
39calledAfter(call: SinonSpyCall): boolean;
40calledWithNew(call: SinonSpyCall): boolean;
41}
42
43interface SinonSpy extends SinonSpyCallApi {
44// Properties
45callCount: number;
46called: boolean;
47notCalled: boolean;
48calledOnce: boolean;
49calledTwice: boolean;
50calledThrice: boolean;
51firstCall: SinonSpyCall;
52secondCall: SinonSpyCall;
53thirdCall: SinonSpyCall;
54lastCall: SinonSpyCall;
55thisValues: any[];
56args: any[][];
57exceptions: any[];
58returnValues: any[];
59
60// Methods
61(...args: any[]): any;
62calledBefore(anotherSpy: SinonSpy): boolean;
63calledAfter(anotherSpy: SinonSpy): boolean;
64calledWithNew(spy: SinonSpy): boolean;
65withArgs(...args: any[]): SinonSpy;
66alwaysCalledOn(obj: any): boolean;
67alwaysCalledWith(...args: any[]): boolean;
68alwaysCalledWithExactly(...args: any[]): boolean;
69alwaysCalledWithMatch(...args: any[]): boolean;
70neverCalledWith(...args: any[]): boolean;
71neverCalledWithMatch(...args: any[]): boolean;
72alwaysThrew(): boolean;
73alwaysThrew(type: string): boolean;
74alwaysThrew(obj: any): boolean;
75alwaysReturned(): boolean;
76invokeCallback(...args: any[]): void;
77getCall(n: number): SinonSpyCall;
78reset(): void;
79printf(format: string, ...args: any[]): string;
80restore(): void;
81}
82
83interface SinonSpyStatic {
84(): SinonSpy;
85(func: any): SinonSpy;
86(obj: any, method: string): SinonSpy;
87}
88
89interface SinonStatic {
90spy: SinonSpyStatic;
91}
92
93interface SinonStub extends SinonSpy {
94resetBehavior(): void;
95returns(obj: any): SinonStub;
96returnsArg(index: number): SinonStub;
97returnsThis(): SinonStub;
98throws(type?: string): SinonStub;
99throws(obj: any): SinonStub;
100callsArg(index: number): SinonStub;
101callsArgOn(index: number, context: any): SinonStub;
102callsArgWith(index: number, ...args: any[]): SinonStub;
103callsArgOnWith(index: number, context: any, ...args: any[]): SinonStub;
104callsArgAsync(index: number): SinonStub;
105callsArgOnAsync(index: number, context: any): SinonStub;
106callsArgWithAsync(index: number, ...args: any[]): SinonStub;
107callsArgOnWithAsync(index: number, context: any, ...args: any[]): SinonStub;
108onCall(n: number): SinonStub;
109onFirstCall(): SinonStub;
110onSecondCall(): SinonStub;
111onThirdCall(): SinonStub;
112yields(...args: any[]): SinonStub;
113yieldsOn(context: any, ...args: any[]): SinonStub;
114yieldsTo(property: string, ...args: any[]): SinonStub;
115yieldsToOn(property: string, context: any, ...args: any[]): SinonStub;
116yieldsAsync(...args: any[]): SinonStub;
117yieldsOnAsync(context: any, ...args: any[]): SinonStub;
118yieldsToAsync(property: string, ...args: any[]): SinonStub;
119yieldsToOnAsync(property: string, context: any, ...args: any[]): SinonStub;
120withArgs(...args: any[]): SinonStub;
121}
122
123interface SinonStubStatic {
124(): SinonStub;
125(obj: any): SinonStub;
126(obj: any, method: string): SinonStub;
127(obj: any, method: string, func: any): SinonStub;
128}
129
130interface SinonStatic {
131stub: SinonStubStatic;
132}
133
134interface SinonExpectation extends SinonStub {
135atLeast(n: number): SinonExpectation;
136atMost(n: number): SinonExpectation;
137never(): SinonExpectation;
138once(): SinonExpectation;
139twice(): SinonExpectation;
140thrice(): SinonExpectation;
141exactly(n: number): SinonExpectation;
142withArgs(...args: any[]): SinonExpectation;
143withExactArgs(...args: any[]): SinonExpectation;
144on(obj: any): SinonExpectation;
145verify(): SinonExpectation;
146restore(): void;
147}
148
149interface SinonExpectationStatic {
150create(methodName?: string): SinonExpectation;
151}
152
153interface SinonMock {
154expects(method: string): SinonExpectation;
155restore(): void;
156verify(): void;
157}
158
159interface SinonMockStatic {
160(): SinonExpectation;
161(obj: any): SinonMock;
162}
163
164interface SinonStatic {
165expectation: SinonExpectationStatic;
166mock: SinonMockStatic;
167}
168
169interface SinonFakeTimers {
170now: number;
171create(now: number): SinonFakeTimers;
172setTimeout(callback: (...args: any[]) => void, timeout: number, ...args: any[]): number;
173clearTimeout(id: number): void;
174setInterval(callback: (...args: any[]) => void, timeout: number, ...args: any[]): number;
175clearInterval(id: number): void;
176tick(ms: number): number;
177reset(): void;
178Date(): Date;
179Date(year: number): Date;
180Date(year: number, month: number): Date;
181Date(year: number, month: number, day: number): Date;
182Date(year: number, month: number, day: number, hour: number): Date;
183Date(year: number, month: number, day: number, hour: number, minute: number): Date;
184Date(year: number, month: number, day: number, hour: number, minute: number, second: number): Date;
185Date(year: number, month: number, day: number, hour: number, minute: number, second: number, ms: number): Date;
186restore(): void;
187
188/**
189* Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp
190* without affecting timers, intervals or immediates.
191* @param now The new 'now' in unix milliseconds
192*/
193setSystemTime(now: number): void;
194/**
195* Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp
196* without affecting timers, intervals or immediates.
197* @param now The new 'now' as a JavaScript Date
198*/
199setSystemTime(date: Date): void;
200}
201
202interface SinonFakeTimersStatic {
203(): SinonFakeTimers;
204(...timers: string[]): SinonFakeTimers;
205(now: number, ...timers: string[]): SinonFakeTimers;
206}
207
208interface SinonStatic {
209useFakeTimers: SinonFakeTimersStatic;
210clock: SinonFakeTimers;
211}
212
213interface SinonFakeUploadProgress {
214eventListeners: {
215progress: any[];
216load: any[];
217abort: any[];
218error: any[];
219};
220
221addEventListener(event: string, listener: (e: Event) => any): void;
222removeEventListener(event: string, listener: (e: Event) => any): void;
223dispatchEvent(event: Event): void;
224}
225
226interface SinonFakeXMLHttpRequest {
227// Properties
228onCreate: (xhr: SinonFakeXMLHttpRequest) => void;
229url: string;
230method: string;
231requestHeaders: any;
232requestBody: string;
233status: number;
234statusText: string;
235async: boolean;
236username: string;
237password: string;
238withCredentials: boolean;
239upload: SinonFakeUploadProgress;
240responseXML: Document;
241getResponseHeader(header: string): string;
242getAllResponseHeaders(): any;
243
244// Methods
245restore(): void;
246useFilters: boolean;
247addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void;
248setResponseHeaders(headers: any): void;
249setResponseBody(body: string): void;
250respond(status: number, headers: any, body: string): void;
251autoRespond(ms: number): void;
252}
253
254interface SinonFakeXMLHttpRequestStatic {
255(): SinonFakeXMLHttpRequest;
256}
257
258interface SinonStatic {
259useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
260FakeXMLHttpRequest: SinonFakeXMLHttpRequest;
261}
262
263interface SinonFakeServer {
264// Properties
265autoRespond: boolean;
266autoRespondAfter: number;
267fakeHTTPMethods: boolean;
268getHTTPMethod: (request: SinonFakeXMLHttpRequest) => string;
269requests: SinonFakeXMLHttpRequest[];
270respondImmediately: boolean;
271
272// Methods
273respondWith(body: string): void;
274respondWith(response: any[]): void;
275respondWith(fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
276respondWith(url: string, body: string): void;
277respondWith(url: string, response: any[]): void;
278respondWith(url: string, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
279respondWith(method: string, url: string, body: string): void;
280respondWith(method: string, url: string, response: any[]): void;
281respondWith(method: string, url: string, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
282respondWith(url: RegExp, body: string): void;
283respondWith(url: RegExp, response: any[]): void;
284respondWith(url: RegExp, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
285respondWith(method: string, url: RegExp, body: string): void;
286respondWith(method: string, url: RegExp, response: any[]): void;
287respondWith(method: string, url: RegExp, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
288respond(): void;
289restore(): void;
290}
291
292interface SinonFakeServerStatic {
293create(): SinonFakeServer;
294}
295
296interface SinonStatic {
297fakeServer: SinonFakeServerStatic;
298fakeServerWithClock: SinonFakeServerStatic;
299}
300
301interface SinonExposeOptions {
302prefix?: string;
303includeFail?: boolean;
304}
305
306interface SinonAssert {
307// Properties
308failException: string;
309fail: (message?: string) => void; // Overridable
310pass: (assertion: any) => void; // Overridable
311
312// Methods
313notCalled(spy: SinonSpy): void;
314called(spy: SinonSpy): void;
315calledOnce(spy: SinonSpy): void;
316calledTwice(spy: SinonSpy): void;
317calledThrice(spy: SinonSpy): void;
318callCount(spy: SinonSpy, count: number): void;
319callOrder(...spies: SinonSpy[]): void;
320calledOn(spy: SinonSpy, obj: any): void;
321alwaysCalledOn(spy: SinonSpy, obj: any): void;
322calledWith(spy: SinonSpy, ...args: any[]): void;
323alwaysCalledWith(spy: SinonSpy, ...args: any[]): void;
324neverCalledWith(spy: SinonSpy, ...args: any[]): void;
325calledWithExactly(spy: SinonSpy, ...args: any[]): void;
326alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void;
327calledWithMatch(spy: SinonSpy, ...args: any[]): void;
328alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void;
329neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void;
330threw(spy: SinonSpy): void;
331threw(spy: SinonSpy, exception: string): void;
332threw(spy: SinonSpy, exception: any): void;
333alwaysThrew(spy: SinonSpy): void;
334alwaysThrew(spy: SinonSpy, exception: string): void;
335alwaysThrew(spy: SinonSpy, exception: any): void;
336expose(obj: any, options?: SinonExposeOptions): void;
337}
338
339interface SinonStatic {
340assert: SinonAssert;
341}
342
343interface SinonMatcher {
344and(expr: SinonMatcher): SinonMatcher;
345or(expr: SinonMatcher): SinonMatcher;
346}
347
348interface SinonMatch {
349(value: number): SinonMatcher;
350(value: string): SinonMatcher;
351(expr: RegExp): SinonMatcher;
352(obj: any): SinonMatcher;
353(callback: (value: any) => boolean): SinonMatcher;
354any: SinonMatcher;
355defined: SinonMatcher;
356truthy: SinonMatcher;
357falsy: SinonMatcher;
358bool: SinonMatcher;
359number: SinonMatcher;
360string: SinonMatcher;
361object: SinonMatcher;
362func: SinonMatcher;
363array: SinonMatcher;
364regexp: SinonMatcher;
365date: SinonMatcher;
366same(obj: any): SinonMatcher;
367typeOf(type: string): SinonMatcher;
368instanceOf(type: any): SinonMatcher;
369has(property: string, expect?: any): SinonMatcher;
370hasOwn(property: string, expect?: any): SinonMatcher;
371}
372
373interface SinonStatic {
374match: SinonMatch;
375}
376
377interface SinonSandboxConfig {
378injectInto?: any;
379properties?: string[];
380useFakeTimers?: any;
381useFakeServer?: any;
382}
383
384interface SinonSandbox {
385clock: SinonFakeTimers;
386requests: SinonFakeXMLHttpRequest;
387server: SinonFakeServer;
388spy: SinonSpyStatic;
389stub: SinonStubStatic;
390mock: SinonMockStatic;
391useFakeTimers: SinonFakeTimersStatic;
392useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
393useFakeServer(): SinonFakeServer;
394restore(): void;
395}
396
397interface SinonSandboxStatic {
398create(): SinonSandbox;
399create(config: SinonSandboxConfig): SinonSandbox;
400}
401
402interface SinonStatic {
403sandbox: SinonSandboxStatic;
404}
405
406interface SinonTestConfig {
407injectIntoThis?: boolean;
408injectInto?: any;
409properties?: string[];
410useFakeTimers?: boolean;
411useFakeServer?: boolean;
412}
413
414interface SinonTestWrapper extends SinonSandbox {
415(...args: any[]): any;
416}
417
418interface SinonStatic {
419config: SinonTestConfig;
420test(fn: (...args: any[]) => any): SinonTestWrapper;
421testCase(tests: any): any;
422}
423
424// Utility overridables
425interface SinonStatic {
426createStubInstance(constructor: any): SinonStub;
427format(obj: any): string;
428log(message: string): void;
429restore(object: any): void;
430}
431}
432
433declare var sinon: Sinon.SinonStatic;
434
435declare module "sinon" {
436export = sinon;
437}