microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
indexed-sourcemap-null-section-issue

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/typings/sinon/sinon.d.ts

460lines · 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
176f99c8ConnorQi013 months ago6declare namespace Sinon {
db80cd4eJimmy Thomson10 years ago7interface 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;
176f99c8ConnorQi013 months ago184Date(
185year: number,
186month: number,
187day: number,
188hour: number,
189minute: number,
190second: number,
191): Date;
192Date(
193year: number,
194month: number,
195day: number,
196hour: number,
197minute: number,
198second: number,
199ms: number,
200): Date;
db80cd4eJimmy Thomson10 years ago201restore(): void;
202
176f99c8ConnorQi013 months ago203/**
204* Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp
205* without affecting timers, intervals or immediates.
206* @param now The new 'now' in unix milliseconds
207*/
208setSystemTime(now: number): void;
209/**
210* Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp
211* without affecting timers, intervals or immediates.
212* @param now The new 'now' as a JavaScript Date
213*/
214setSystemTime(date: Date): void;
215}
db80cd4eJimmy Thomson10 years ago216
217interface SinonFakeTimersStatic {
218(): SinonFakeTimers;
219(...timers: string[]): SinonFakeTimers;
220(now: number, ...timers: string[]): SinonFakeTimers;
221}
222
223interface SinonStatic {
224useFakeTimers: SinonFakeTimersStatic;
225clock: SinonFakeTimers;
226}
227
228interface SinonFakeUploadProgress {
229eventListeners: {
230progress: any[];
231load: any[];
232abort: any[];
233error: any[];
234};
235
236addEventListener(event: string, listener: (e: Event) => any): void;
237removeEventListener(event: string, listener: (e: Event) => any): void;
238dispatchEvent(event: Event): void;
239}
240
241interface SinonFakeXMLHttpRequest {
242// Properties
243onCreate: (xhr: SinonFakeXMLHttpRequest) => void;
244url: string;
245method: string;
246requestHeaders: any;
247requestBody: string;
248status: number;
249statusText: string;
250async: boolean;
251username: string;
252password: string;
253withCredentials: boolean;
254upload: SinonFakeUploadProgress;
255responseXML: Document;
256getResponseHeader(header: string): string;
257getAllResponseHeaders(): any;
258
259// Methods
260restore(): void;
261useFilters: boolean;
176f99c8ConnorQi013 months ago262addFilter(
263filter: (
264method: string,
265url: string,
266async: boolean,
267username: string,
268password: string,
269) => boolean,
270): void;
db80cd4eJimmy Thomson10 years ago271setResponseHeaders(headers: any): void;
272setResponseBody(body: string): void;
273respond(status: number, headers: any, body: string): void;
274autoRespond(ms: number): void;
275}
276
277interface SinonFakeXMLHttpRequestStatic {
278(): SinonFakeXMLHttpRequest;
279}
280
281interface SinonStatic {
282useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
283FakeXMLHttpRequest: SinonFakeXMLHttpRequest;
284}
285
286interface SinonFakeServer {
287// Properties
288autoRespond: boolean;
289autoRespondAfter: number;
290fakeHTTPMethods: boolean;
291getHTTPMethod: (request: SinonFakeXMLHttpRequest) => string;
292requests: SinonFakeXMLHttpRequest[];
293respondImmediately: boolean;
294
295// Methods
296respondWith(body: string): void;
297respondWith(response: any[]): void;
298respondWith(fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
299respondWith(url: string, body: string): void;
300respondWith(url: string, response: any[]): void;
301respondWith(url: string, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
302respondWith(method: string, url: string, body: string): void;
303respondWith(method: string, url: string, response: any[]): void;
304respondWith(method: string, url: string, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
305respondWith(url: RegExp, body: string): void;
306respondWith(url: RegExp, response: any[]): void;
307respondWith(url: RegExp, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
308respondWith(method: string, url: RegExp, body: string): void;
309respondWith(method: string, url: RegExp, response: any[]): void;
310respondWith(method: string, url: RegExp, fn: (xhr: SinonFakeXMLHttpRequest) => void): void;
311respond(): void;
312restore(): void;
313}
314
315interface SinonFakeServerStatic {
316create(): SinonFakeServer;
317}
318
319interface SinonStatic {
320fakeServer: SinonFakeServerStatic;
321fakeServerWithClock: SinonFakeServerStatic;
322}
323
324interface SinonExposeOptions {
325prefix?: string;
326includeFail?: boolean;
327}
328
329interface SinonAssert {
330// Properties
331failException: string;
332fail: (message?: string) => void; // Overridable
333pass: (assertion: any) => void; // Overridable
334
335// Methods
336notCalled(spy: SinonSpy): void;
337called(spy: SinonSpy): void;
338calledOnce(spy: SinonSpy): void;
339calledTwice(spy: SinonSpy): void;
340calledThrice(spy: SinonSpy): void;
341callCount(spy: SinonSpy, count: number): void;
342callOrder(...spies: SinonSpy[]): void;
343calledOn(spy: SinonSpy, obj: any): void;
344alwaysCalledOn(spy: SinonSpy, obj: any): void;
345calledWith(spy: SinonSpy, ...args: any[]): void;
346alwaysCalledWith(spy: SinonSpy, ...args: any[]): void;
347neverCalledWith(spy: SinonSpy, ...args: any[]): void;
348calledWithExactly(spy: SinonSpy, ...args: any[]): void;
349alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void;
350calledWithMatch(spy: SinonSpy, ...args: any[]): void;
351alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void;
352neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void;
353threw(spy: SinonSpy): void;
354threw(spy: SinonSpy, exception: string): void;
355threw(spy: SinonSpy, exception: any): void;
356alwaysThrew(spy: SinonSpy): void;
357alwaysThrew(spy: SinonSpy, exception: string): void;
358alwaysThrew(spy: SinonSpy, exception: any): void;
359expose(obj: any, options?: SinonExposeOptions): void;
360}
361
362interface SinonStatic {
363assert: SinonAssert;
364}
365
366interface SinonMatcher {
367and(expr: SinonMatcher): SinonMatcher;
368or(expr: SinonMatcher): SinonMatcher;
369}
370
371interface SinonMatch {
372(value: number): SinonMatcher;
373(value: string): SinonMatcher;
374(expr: RegExp): SinonMatcher;
375(obj: any): SinonMatcher;
376(callback: (value: any) => boolean): SinonMatcher;
377any: SinonMatcher;
378defined: SinonMatcher;
379truthy: SinonMatcher;
380falsy: SinonMatcher;
381bool: SinonMatcher;
382number: SinonMatcher;
383string: SinonMatcher;
384object: SinonMatcher;
385func: SinonMatcher;
386array: SinonMatcher;
387regexp: SinonMatcher;
388date: SinonMatcher;
389same(obj: any): SinonMatcher;
390typeOf(type: string): SinonMatcher;
391instanceOf(type: any): SinonMatcher;
392has(property: string, expect?: any): SinonMatcher;
393hasOwn(property: string, expect?: any): SinonMatcher;
394}
395
396interface SinonStatic {
397match: SinonMatch;
398}
399
400interface SinonSandboxConfig {
401injectInto?: any;
402properties?: string[];
403useFakeTimers?: any;
404useFakeServer?: any;
405}
406
407interface SinonSandbox {
408clock: SinonFakeTimers;
409requests: SinonFakeXMLHttpRequest;
410server: SinonFakeServer;
411spy: SinonSpyStatic;
412stub: SinonStubStatic;
413mock: SinonMockStatic;
414useFakeTimers: SinonFakeTimersStatic;
415useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
416useFakeServer(): SinonFakeServer;
417restore(): void;
418}
419
420interface SinonSandboxStatic {
421create(): SinonSandbox;
422create(config: SinonSandboxConfig): SinonSandbox;
423}
424
425interface SinonStatic {
426sandbox: SinonSandboxStatic;
427}
428
429interface SinonTestConfig {
430injectIntoThis?: boolean;
431injectInto?: any;
432properties?: string[];
433useFakeTimers?: boolean;
434useFakeServer?: boolean;
435}
436
437interface SinonTestWrapper extends SinonSandbox {
438(...args: any[]): any;
439}
440
441interface SinonStatic {
442config: SinonTestConfig;
443test(fn: (...args: any[]) => any): SinonTestWrapper;
444testCase(tests: any): any;
445}
446
447// Utility overridables
448interface SinonStatic {
449createStubInstance(constructor: any): SinonStub;
450format(obj: any): string;
451log(message: string): void;
452restore(object: any): void;
453}
454}
455
456declare var sinon: Sinon.SinonStatic;
457
458declare module "sinon" {
459export = sinon;
460}