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