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