diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 2e8853625a..ef6d69066d 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -492,9 +492,22 @@ } }, "node_modules/@types/sinon": { - "version": "7.5.2", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.2.tgz", + "integrity": "sha512-BHn8Bpkapj8Wdfxvh2jWIUoaYB/9/XhsL0oOvBfRagJtKlSl9NWPcFOz2lRukI9szwGxFtYZCTejJSqsGDbdmw==", "dev": true, - "license": "MIT" + "dependencies": { + "@sinonjs/fake-timers": "^7.1.0" + } + }, + "node_modules/@types/sinon/node_modules/@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^1.7.0" + } }, "node_modules/@types/tmp": { "version": "0.1.0", diff --git a/node_modules/@types/sinon/LICENSE b/node_modules/@types/sinon/LICENSE old mode 100644 new mode 100755 index 4b1ad51b2f..9e841e7a26 --- a/node_modules/@types/sinon/LICENSE +++ b/node_modules/@types/sinon/LICENSE @@ -1,21 +1,21 @@ - MIT License - - Copyright (c) Microsoft Corporation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/node_modules/@types/sinon/README.md b/node_modules/@types/sinon/README.md old mode 100644 new mode 100755 index ef61f72758..4efd350399 --- a/node_modules/@types/sinon/README.md +++ b/node_modules/@types/sinon/README.md @@ -8,9 +8,9 @@ This package contains type definitions for Sinon (https://sinonjs.org). Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sinon. ### Additional Details - * Last updated: Tue, 25 Feb 2020 18:51:13 GMT - * Dependencies: none + * Last updated: Wed, 02 Jun 2021 06:01:28 GMT + * Dependencies: [@types/sinonjs__fake-timers](https://npmjs.com/package/@types/sinonjs__fake-timers) * Global values: `sinon` # Credits -These definitions were written by [William Sears](https://github.com/mrbigdog2u), [Jonathan Little](https://github.com/rationull), [Lukas Spieß](https://github.com/lumaxis), [Nico Jansen](https://github.com/nicojs), [James Garbutt](https://github.com/43081j), [Josh Goldberg](https://github.com/joshuakgoldberg), [Greg Jednaszewski](https://github.com/gjednaszewski), [John Wood](https://github.com/johnjesse), [Alec Flett](https://github.com/alecf), [Simon Schick](https://github.com/SimonSchick), and [Roey Berman](https://github.com/bergundy). +These definitions were written by [William Sears](https://github.com/mrbigdog2u), [Lukas Spieß](https://github.com/lumaxis), [Nico Jansen](https://github.com/nicojs), [James Garbutt](https://github.com/43081j), [Josh Goldberg](https://github.com/joshuakgoldberg), [Greg Jednaszewski](https://github.com/gjednaszewski), [John Wood](https://github.com/johnjesse), [Alec Flett](https://github.com/alecf), and [Simon Schick](https://github.com/SimonSchick). diff --git a/node_modules/@types/sinon/index.d.ts b/node_modules/@types/sinon/index.d.ts old mode 100644 new mode 100755 index af518c32d4..aca182a329 --- a/node_modules/@types/sinon/index.d.ts +++ b/node_modules/@types/sinon/index.d.ts @@ -1,7 +1,6 @@ -// Type definitions for Sinon 7.5 +// Type definitions for Sinon 10.0 // Project: https://sinonjs.org // Definitions by: William Sears -// Jonathan Little // Lukas Spieß // Nico Jansen // James Garbutt @@ -10,23 +9,27 @@ // John Wood // Alec Flett // Simon Schick -// Roey Berman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 + +import * as FakeTimers from "@sinonjs/fake-timers"; // sinon uses DOM dependencies which are absent in browser-less environment like node.js // to avoid compiler errors this monkey patch is used // see more details in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11351 -interface Event { } // tslint:disable-line no-empty-interface -interface Document { } // tslint:disable-line no-empty-interface +interface Event {} // tslint:disable-line no-empty-interface +interface Document {} // tslint:disable-line no-empty-interface declare namespace Sinon { - interface SinonSpyCallApi { + type MatchArguments = { + [K in keyof T]: SinonMatcher | (T[K] extends object ? MatchArguments : never) | T[K]; + }; + + interface SinonSpyCallApi { // Properties /** * Array of received arguments. */ - args: any[]; + args: TArgs; // Methods /** @@ -41,11 +44,11 @@ declare namespace Sinon { * so a call that received the provided arguments (in the same spots) and possibly others as well will return true. * @param args */ - calledWith(...args: any[]): boolean; + calledWith(...args: Partial>): boolean; /** * Returns true if spy was called at least once with the provided arguments and no others. */ - calledWithExactly(...args: any[]): boolean; + calledWithExactly(...args: MatchArguments): boolean; /** * Returns true if spy/stub was called the new operator. * Beware that this is inferred based on the value of the this object and the spy function’s prototype, @@ -56,31 +59,31 @@ declare namespace Sinon { * Returns true if spy was called at exactly once with the provided arguments. * @param args */ - calledOnceWith(...args: any[]): boolean; - calledOnceWithExactly(...args: any[]): boolean; + calledOnceWith(...args: MatchArguments): boolean; + calledOnceWithExactly(...args: MatchArguments): boolean; /** * Returns true if spy was called with matching arguments (and possibly others). * This behaves the same as spy.calledWith(sinon.match(arg1), sinon.match(arg2), ...). * @param args */ - calledWithMatch(...args: any[]): boolean; + calledWithMatch(...args: TArgs): boolean; /** * Returns true if call did not receive provided arguments. * @param args */ - notCalledWith(...args: any[]): boolean; + notCalledWith(...args: MatchArguments): boolean; /** * Returns true if call did not receive matching arguments. * This behaves the same as spyCall.notCalledWith(sinon.match(arg1), sinon.match(arg2), ...). * @param args */ - notCalledWithMatch(...args: any[]): boolean; + notCalledWithMatch(...args: TArgs): boolean; /** * Returns true if spy returned the provided value at least once. * Uses deep comparison for objects and arrays. Use spy.returned(sinon.match.same(obj)) for strict comparison (see matchers). * @param value */ - returned(value: any): boolean; + returned(value: TReturnValue | SinonMatcher): boolean; /** * Returns true if spy threw an exception at least once. */ @@ -121,7 +124,8 @@ declare namespace Sinon { yieldToOn(property: string, obj: any, ...args: any[]): void; } - interface SinonSpyCall extends SinonSpyCallApi { + interface SinonSpyCall + extends SinonSpyCallApi { /** * The call’s this value. */ @@ -133,12 +137,18 @@ declare namespace Sinon { /** * Return value. */ - returnValue: any; + returnValue: TReturnValue; /** * This property is a convenience for a call’s callback. * When the last argument in a call is a Function, then callback will reference that. Otherwise it will be undefined. */ callback: Function | undefined; + + /** + * This property is a convenience for the first argument of the call. + */ + firstArg: any; + /** * This property is a convenience for the last argument of the call. */ @@ -147,16 +157,21 @@ declare namespace Sinon { /** * Returns true if the spy call occurred before another spy call. * @param call + * */ - calledBefore(call: SinonSpyCall): boolean; + calledBefore(call: SinonSpyCall): boolean; /** * Returns true if the spy call occurred after another spy call. * @param call */ - calledAfter(call: SinonSpyCall): boolean; + calledAfter(call: SinonSpyCall): boolean; } - interface SinonSpy extends SinonSpyCallApi { + interface SinonSpy + extends Pick< + SinonSpyCallApi, + Exclude, "args"> + > { // Properties /** * The number of recorded calls. @@ -185,19 +200,19 @@ declare namespace Sinon { /** * The first call */ - firstCall: SinonSpyCall; + firstCall: SinonSpyCall; /** * The second call */ - secondCall: SinonSpyCall; + secondCall: SinonSpyCall; /** * The third call */ - thirdCall: SinonSpyCall; + thirdCall: SinonSpyCall; /** * The last call */ - lastCall: SinonSpyCall; + lastCall: SinonSpyCall; /** * Array of this objects, spy.thisValues[0] is the this object for the first call. */ @@ -205,7 +220,7 @@ declare namespace Sinon { /** * Array of arguments received, spy.args[0] is an array of arguments received in the first call. */ - args: any[][]; + args: TArgs[]; /** * Array of exception objects thrown, spy.exceptions[0] is the exception thrown by the first call. * If the call did not throw an error, the value at the call’s location in .exceptions will be undefined. @@ -215,36 +230,43 @@ declare namespace Sinon { * Array of return values, spy.returnValues[0] is the return value of the first call. * If the call did not explicitly return a value, the value at the call’s location in .returnValues will be undefined. */ - returnValues: any[]; + returnValues: TReturnValue[]; + + /** + * Holds a reference to the original method/function this stub has wrapped. + */ + wrappedMethod: (...args: TArgs) => TReturnValue; // Methods - (...args: any[]): any; + (...args: TArgs): TReturnValue; + /** * Returns true if the spy was called before @param anotherSpy * @param anotherSpy */ - calledBefore(anotherSpy: SinonSpy): boolean; + calledBefore(anotherSpy: SinonSpy): boolean; /** * Returns true if the spy was called after @param anotherSpy * @param anotherSpy */ - calledAfter(anotherSpy: SinonSpy): boolean; + calledAfter(anotherSpy: SinonSpy): boolean; /** * Returns true if spy was called before @param anotherSpy, and no spy calls occurred between spy and @param anotherSpy. * @param anotherSpy */ - calledImmediatelyBefore(anotherSpy: SinonSpy): boolean; + calledImmediatelyBefore(anotherSpy: SinonSpy): boolean; /** * Returns true if spy was called after @param anotherSpy, and no spy calls occurred between @param anotherSpy and spy. * @param anotherSpy */ - calledImmediatelyAfter(anotherSpy: SinonSpy): boolean; + calledImmediatelyAfter(anotherSpy: SinonSpy): boolean; + /** * Creates a spy that only records calls when the received arguments match those passed to withArgs. * This is useful to be more expressive in your assertions, where you can access the spy with the same call. * @param args Expected args */ - withArgs(...args: any[]): SinonSpy; + withArgs(...args: MatchArguments): SinonSpy; /** * Returns true if the spy was always called with @param obj as this. * @param obj @@ -253,29 +275,29 @@ declare namespace Sinon { /** * Returns true if spy was always called with the provided arguments (and possibly others). */ - alwaysCalledWith(...args: any[]): boolean; + alwaysCalledWith(...args: MatchArguments): boolean; /** * Returns true if spy was always called with the exact provided arguments. * @param args */ - alwaysCalledWithExactly(...args: any[]): boolean; + alwaysCalledWithExactly(...args: MatchArguments): boolean; /** * Returns true if spy was always called with matching arguments (and possibly others). * This behaves the same as spy.alwaysCalledWith(sinon.match(arg1), sinon.match(arg2), ...). * @param args */ - alwaysCalledWithMatch(...args: any[]): boolean; + alwaysCalledWithMatch(...args: TArgs): boolean; /** * Returns true if the spy/stub was never called with the provided arguments. * @param args */ - neverCalledWith(...args: any[]): boolean; + neverCalledWith(...args: MatchArguments): boolean; /** * Returns true if the spy/stub was never called with matching arguments. * This behaves the same as spy.neverCalledWith(sinon.match(arg1), sinon.match(arg2), ...). * @param args */ - neverCalledWithMatch(...args: any[]): boolean; + neverCalledWithMatch(...args: TArgs): boolean; /** * Returns true if spy always threw an exception. */ @@ -298,22 +320,22 @@ declare namespace Sinon { * If the stub was never called with a function argument, yield throws an error. * Returns an Array with all callbacks return values in the order they were called, if no error is thrown. */ - invokeCallback(...args: any[]): void; + invokeCallback(...args: TArgs): void; /** * Set the displayName of the spy or stub. * @param name */ - named(name: string): SinonSpy; + named(name: string): SinonSpy; /** * Returns the nth call. * Accessing individual calls helps with more detailed behavior verification when the spy is called more than once. - * @param n + * @param n Zero based index of the spy call. */ - getCall(n: number): SinonSpyCall; + getCall(n: number): SinonSpyCall; /** * Returns an Array of all calls recorded by the spy. */ - getCalls(): SinonSpyCall[]; + getCalls(): Array>; /** * Resets the state of a spy. */ @@ -345,7 +367,11 @@ declare namespace Sinon { /** * Spies on the provided function */ - (func: Function): SinonSpy; + any>(func: F): SinonSpy, ReturnType>; + /** + * Spies on all the object’s methods. + */ + (obj: T): SinonSpiedInstance; /** * Creates a spy for object.method and replaces the original method with the spy. * An exception is thrown if the property is not already a function. @@ -353,10 +379,25 @@ declare namespace Sinon { * The original method can be restored by calling object.method.restore(). * The returned spy is the function object which replaced the original method. spy === object.method. */ - (obj: T, method: keyof T, types?: string[]): SinonSpy; + (obj: T, method: K): T[K] extends (...args: infer TArgs) => infer TReturnValue + ? SinonSpy + : SinonSpy; + + (obj: T, method: K, types: Array<"get" | "set">): PropertyDescriptor & { + get: SinonSpy<[], T[K]>; + set: SinonSpy<[T[K]], void>; + }; } - interface SinonStub extends SinonSpy { + type SinonSpiedInstance = { + [P in keyof T]: SinonSpiedMember; + }; + + type SinonSpiedMember = T extends (...args: infer TArgs) => infer TReturnValue + ? SinonSpy + : T; + + interface SinonStub extends SinonSpy { /** * Resets the stub’s behaviour to the default behaviour * You can reset behaviour of all stubs using sinon.resetBehavior() @@ -374,13 +415,13 @@ declare namespace Sinon { * Causes the stub to return promises using a specific Promise library instead of the global one when using stub.rejects or stub.resolves. * Returns the stub to allow chaining. */ - usingPromise(promiseLibrary: any): SinonStub; + usingPromise(promiseLibrary: any): SinonStub; /** * Makes the stub return the provided @param obj value. * @param obj */ - returns(obj: any): SinonStub; + returns(obj: TReturnValue): SinonStub; /** * Causes the stub to return the argument at the provided @param index. * stub.returnsArg(0); causes the stub to return the first argument. @@ -388,12 +429,12 @@ declare namespace Sinon { * starting from sinon@6.1.2, a TypeError will be thrown. * @param index */ - returnsArg(index: number): SinonStub; + returnsArg(index: number): SinonStub; /** * Causes the stub to return its this value. * Useful for stubbing jQuery-style fluent APIs. */ - returnsThis(): SinonStub; + returnsThis(): SinonStub; /** * Causes the stub to return a Promise which resolves to the provided value. * When constructing the Promise, sinon uses the Promise.resolve method. @@ -401,26 +442,28 @@ declare namespace Sinon { * The Promise library can be overwritten using the usingPromise method. * Since sinon@2.0.0 */ - resolves(value?: any): SinonStub; + resolves( + value?: TReturnValue extends PromiseLike ? TResolveValue : any, + ): SinonStub; /** * Causes the stub to return a Promise which resolves to the argument at the provided index. * stub.resolvesArg(0); causes the stub to return a Promise which resolves to the first argument. * If the argument at the provided index is not available, a TypeError will be thrown. */ - resolvesArg(index: number): SinonStub; + resolvesArg(index: number): SinonStub; /** * Causes the stub to return a Promise which resolves to its this value. */ - resolvesThis(): SinonStub; + resolvesThis(): SinonStub; /** * Causes the stub to throw an exception (Error). * @param type */ - throws(type?: string): SinonStub; + throws(type?: string): SinonStub; /** * Causes the stub to throw the provided exception object. */ - throws(obj: any): SinonStub; + throws(obj: any): SinonStub; /** * Causes the stub to throw the argument at the provided index. * stub.throwsArg(0); causes the stub to throw the first argument as the exception. @@ -428,9 +471,9 @@ declare namespace Sinon { * Since sinon@2.3.0 * @param index */ - throwsArg(index: number): SinonStub; - throwsException(type?: string): SinonStub; - throwsException(obj: any): SinonStub; + throwsArg(index: number): SinonStub; + throwsException(type?: string): SinonStub; + throwsException(obj: any): SinonStub; /** * Causes the stub to return a Promise which rejects with an exception (Error). * When constructing the Promise, sinon uses the Promise.reject method. @@ -438,53 +481,53 @@ declare namespace Sinon { * The Promise library can be overwritten using the usingPromise method. * Since sinon@2.0.0 */ - rejects(): SinonStub; + rejects(): SinonStub; /** * Causes the stub to return a Promise which rejects with an exception of the provided type. * Since sinon@2.0.0 */ - rejects(errorType: string): SinonStub; + rejects(errorType: string): SinonStub; /** * Causes the stub to return a Promise which rejects with the provided exception object. * Since sinon@2.0.0 */ - rejects(value: any): SinonStub; + rejects(value: any): SinonStub; /** * Causes the stub to call the argument at the provided index as a callback function. * stub.callsArg(0); causes the stub to call the first argument as a callback. * If the argument at the provided index is not available or is not a function, a TypeError will be thrown. */ - callsArg(index: number): SinonStub; + callsArg(index: number): SinonStub; /** * Causes the original method wrapped into the stub to be called when none of the conditional stubs are matched. */ - callThrough(): SinonStub; + callThrough(): SinonStub; /** * Like stub.callsArg(index); but with an additional parameter to pass the this context. * @param index * @param context */ - callsArgOn(index: number, context: any): SinonStub; + callsArgOn(index: number, context: any): SinonStub; /** * Like callsArg, but with arguments to pass to the callback. * @param index * @param args */ - callsArgWith(index: number, ...args: any[]): SinonStub; + callsArgWith(index: number, ...args: any[]): SinonStub; /** * Like above but with an additional parameter to pass the this context. * @param index * @param context * @param args */ - callsArgOnWith(index: number, context: any, ...args: any[]): SinonStub; + callsArgOnWith(index: number, context: any, ...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. * In a browser the callback is deferred with setTimeout(callback, 0). * @param index */ - callsArgAsync(index: number): SinonStub; + callsArgAsync(index: number): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. @@ -492,91 +535,91 @@ declare namespace Sinon { * @param index * @param context */ - callsArgOnAsync(index: number, context: any): SinonStub; + callsArgOnAsync(index: number, context: any): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. * In a browser the callback is deferred with setTimeout(callback, 0). */ - callsArgWithAsync(index: number, ...args: any[]): SinonStub; + callsArgWithAsync(index: number, ...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. * In a browser the callback is deferred with setTimeout(callback, 0). */ - callsArgOnWithAsync(index: number, context: any, ...args: any[]): SinonStub; + callsArgOnWithAsync(index: number, context: any, ...args: any[]): SinonStub; /** * Makes the stub call the provided @param func when invoked. * @param func */ - callsFake(func: (...args: any[]) => any): SinonStub; + callsFake(func: (...args: TArgs) => TReturnValue): SinonStub; /** * Replaces a new getter for this stub. */ - get(func: () => any): SinonStub; + get(func: () => any): SinonStub; /** * Defines a new setter for this stub. * @param func */ - set(func: (v: any) => void): SinonStub; + set(func: (v: any) => void): SinonStub; /** * Defines the behavior of the stub on the @param n call. Useful for testing sequential interactions. * There are methods onFirstCall, onSecondCall,onThirdCall to make stub definitions read more naturally. * onCall can be combined with all of the behavior defining methods in this section. In particular, it can be used together with withArgs. * @param n */ - onCall(n: number): SinonStub; + onCall(n: number): SinonStub; /** * Alias for stub.onCall(0); */ - onFirstCall(): SinonStub; + onFirstCall(): SinonStub; /** * Alias for stub.onCall(1); */ - onSecondCall(): SinonStub; + onSecondCall(): SinonStub; /** * Alias for stub.onCall(2); */ - onThirdCall(): SinonStub; + onThirdCall(): SinonStub; /** * Defines a new value for this stub. * @param val */ - value(val: any): SinonStub; + value(val: any): SinonStub; /** * Set the displayName of the spy or stub. * @param name */ - named(name: string): SinonStub; + named(name: string): SinonStub; /** * Similar to callsArg. * Causes the stub to call the first callback it receives with the provided arguments (if any). * If a method accepts more than one callback, you need to use callsArg to have the stub invoke other callbacks than the first one. */ - yields(...args: any[]): SinonStub; + yields(...args: any[]): SinonStub; /** * Like above but with an additional parameter to pass the this context. */ - yieldsOn(context: any, ...args: any[]): SinonStub; - yieldsRight(...args: any[]): SinonStub; + yieldsOn(context: any, ...args: any[]): SinonStub; + yieldsRight(...args: any[]): SinonStub; /** * Causes the spy to invoke a callback passed as a property of an object to the spy. * Like yields, yieldsTo grabs the first matching argument, finds the callback and calls it with the (optional) arguments. * @param property * @param args */ - yieldsTo(property: string, ...args: any[]): SinonStub; + yieldsTo(property: string, ...args: any[]): SinonStub; /** * Like above but with an additional parameter to pass the this context. */ - yieldsToOn(property: string, context: any, ...args: any[]): SinonStub; + yieldsToOn(property: string, context: any, ...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. * In a browser the callback is deferred with setTimeout(callback, 0). * @param args */ - yieldsAsync(...args: any[]): SinonStub; + yieldsAsync(...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. @@ -584,7 +627,7 @@ declare namespace Sinon { * @param context * @param args */ - yieldsOnAsync(context: any, ...args: any[]): SinonStub; + yieldsOnAsync(context: any, ...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. @@ -592,7 +635,7 @@ declare namespace Sinon { * @param property * @param args */ - yieldsToAsync(property: string, ...args: any[]): SinonStub; + yieldsToAsync(property: string, ...args: any[]): SinonStub; /** * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. * In Node environment the callback is deferred with process.nextTick. @@ -601,21 +644,26 @@ declare namespace Sinon { * @param context * @param args */ - yieldsToOnAsync(property: string, context: any, ...args: any[]): SinonStub; + yieldsToOnAsync(property: string, context: any, ...args: any[]): SinonStub; /** * Stubs the method only for the provided arguments. * This is useful to be more expressive in your assertions, where you can access the spy with the same call. * It is also useful to create a stub that can act differently in response to different arguments. * @param args */ - withArgs(...args: any[]): SinonStub; + withArgs(...args: MatchArguments): SinonStub; } interface SinonStubStatic { + /* tslint:disable:no-unnecessary-generics */ + /** * Creates an anonymous stub function */ - (): SinonStub; + (): SinonStub; + + /* tslint:enable:no-unnecessary-generics */ + /** * Stubs all the object’s methods. * Note that it’s usually better practice to stub individual methods, particularly on objects that you don’t understand or control all the methods for (e.g. library dependencies). @@ -628,7 +676,9 @@ declare namespace Sinon { * An exception is thrown if the property is not already a function. * The original function can be restored by calling object.method.restore(); (or stub.restore();). */ - (obj: T, method: keyof T): SinonStub; + (obj: T, method: K): T[K] extends (...args: infer TArgs) => infer TReturnValue + ? SinonStub + : SinonStub; } interface SinonExpectation extends SinonStub { @@ -725,84 +775,13 @@ declare namespace Sinon { (obj: any): SinonMock; } - type SinonTimerId = number | { id: number }; - - interface SinonFakeTimers { - now: number; - loopLimit: number; - - setTimeout(callback: (...args: any[]) => void, timeout: number, ...args: any[]): SinonTimerId; - clearTimeout(id: SinonTimerId): void; - - setInterval(callback: (...args: any[]) => void, timeout: number, ...args: any[]): SinonTimerId; - clearInterval(id: SinonTimerId): void; - - setImmediate(callback: (...args: any[]) => void, ...args: any[]): SinonTimerId; - clearImmediate(id: SinonTimerId): void; - - requestAnimationFrame(callback: (time: number) => void): SinonTimerId; - cancelAnimationFrame(id: SinonTimerId): void; - - nextTick(callback: (...args: any[]) => void, ...args: any[]): void; - queueMicrotask(callback: () => void): void; - - requestIdleCallback(func: (...args: any[]) => void, timeout?: number, ...args: any[]): SinonTimerId; - cancelIdleCallback(timerId: SinonTimerId): void; - - /** - * Tick the clock ahead time milliseconds. - * Causes all timers scheduled within the affected time range to be called. - * time may be the number of milliseconds to advance the clock by or a human-readable string. - * Valid string formats are “08” for eight seconds, “01:00” for one minute and “02:34:10” for two hours, 34 minutes and ten seconds. - * time may be negative, which causes the clock to change but won’t fire any callbacks. - * @param ms - */ - tick(ms: number | string): number; - /** - * Advances the clock to the the moment of the first scheduled timer, firing it. - */ - next(): number; + type SinonFakeTimers = FakeTimers.Clock & { /** - * This runs all pending timers until there are none remaining. If new timers are added while it is executing they will be run as well. - * This makes it easier to run asynchronous tests to completion without worrying about the number of timers they use, or the delays in those timers. - */ - runAll(): number; - runToLast(): number; - reset(): void; - runMicrotasks(): void; - runToFrame(): number; - - Date(): Date; - Date(year: number): Date; - Date(year: number, month: number): Date; - Date(year: number, month: number, day: number): Date; - Date(year: number, month: number, day: number, hour: number): Date; - Date(year: number, month: number, day: number, hour: number, minute: number): Date; - Date(year: number, month: number, day: number, hour: number, minute: number, second: number): Date; - Date(year: number, month: number, day: number, hour: number, minute: number, second: number, ms: number): Date; - - /** - * Restore the faked methods. - * Call in e.g. tearDown. + * Restores the original clock + * Identical to uninstall() */ restore(): void; - uninstall(): void; - - /** - * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp - * without affecting timers, intervals or immediates. - * @param now The new 'now' in unix milliseconds - */ - setSystemTime(now: number): void; - /** - * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp - * without affecting timers, intervals or immediates. - * @param now The new 'now' as a JavaScript Date - */ - setSystemTime(date: Date): void; - - countTimers(): number; - } + }; interface SinonFakeTimersConfig { now: number | Date; @@ -902,7 +881,7 @@ declare namespace Sinon { } interface SinonFakeXMLHttpRequestStatic { - new(): SinonFakeXMLHttpRequest; + new (): SinonFakeXMLHttpRequest; /** * Default false. * When set to true, Sinon will check added filters if certain requests should be “unfaked” @@ -914,7 +893,9 @@ declare namespace Sinon { * If the filter returns true, the request will not be faked. * @param filter */ - addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void; + addFilter( + filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean, + ): void; /** * By assigning a function to the onCreate property of the returned object from useFakeXMLHttpRequest() * you can subscribe to newly created FakeXMLHttpRequest objects. See below for the fake xhr object API. @@ -1087,133 +1068,155 @@ declare namespace Sinon { pass(assertion: any): void; // Overridable // Methods + /** * Passes if spy was never called * @param spy */ - notCalled(spy: SinonSpy): void; + notCalled(spy: SinonSpy): void; /** * Passes if spy was called at least once. */ - called(spy: SinonSpy): void; + called(spy: SinonSpy): void; /** * Passes if spy was called once and only once. */ - calledOnce(spy: SinonSpy): void; + calledOnce(spy: SinonSpy): void; /** * Passes if spy was called exactly twice. */ - calledTwice(spy: SinonSpy): void; + calledTwice(spy: SinonSpy): void; /** * Passes if spy was called exactly three times. */ - calledThrice(spy: SinonSpy): void; + calledThrice(spy: SinonSpy): void; /** * Passes if spy was called exactly num times. */ - callCount(spy: SinonSpy, count: number): void; + callCount(spy: SinonSpy, count: number): void; /** * Passes if provided spies were called in the specified order. * @param spies */ - callOrder(...spies: SinonSpy[]): void; + callOrder(...spies: Array>): void; /** * Passes if spy was ever called with obj as its this value. * It’s possible to assert on a dedicated spy call: sinon.assert.calledOn(spy.firstCall, arg1, arg2, ...);. */ - calledOn(spyOrSpyCall: SinonSpy | SinonSpyCall, obj: any): void; + calledOn(spyOrSpyCall: SinonSpy | SinonSpyCall, obj: any): void; /** * Passes if spy was always called with obj as its this value. */ - alwaysCalledOn(spy: SinonSpy, obj: any): void; + alwaysCalledOn(spy: SinonSpy, obj: any): void; + /** * Passes if spy was called with the provided arguments. * It’s possible to assert on a dedicated spy call: sinon.assert.calledWith(spy.firstCall, arg1, arg2, ...);. * @param spyOrSpyCall * @param args */ - calledWith(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; + calledWith( + spyOrSpyCall: SinonSpy | SinonSpyCall, + ...args: Partial> + ): void; /** * Passes if spy was always called with the provided arguments. * @param spy * @param args */ - alwaysCalledWith(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWith(spy: SinonSpy, ...args: Partial>): void; /** * Passes if spy was never called with the provided arguments. * @param spy * @param args */ - neverCalledWith(spy: SinonSpy, ...args: any[]): void; + neverCalledWith(spy: SinonSpy, ...args: Partial>): void; /** * Passes if spy was called with the provided arguments and no others. * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithExactly(spy.getCall(1), arg1, arg2, ...);. * @param spyOrSpyCall * @param args */ - calledWithExactly(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; + calledWithExactly( + spyOrSpyCall: SinonSpy | SinonSpyCall, + ...args: MatchArguments + ): void; /** * Passes if spy was called at exactly once with the provided arguments and no others. * @param spyOrSpyCall * @param args */ - calledOnceWithExactly(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; + calledOnceWithExactly( + spyOrSpyCall: SinonSpy | SinonSpyCall, + ...args: MatchArguments + ): void; /** * Passes if spy was always called with the provided arguments and no others. */ - alwaysCalledWithExactly(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWithExactly(spy: SinonSpy, ...args: MatchArguments): void; /** * Passes if spy was called with matching arguments. * This behaves the same way as sinon.assert.calledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). - * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithMatch(spy.secondCall, arg1, arg2, ...);. + * It's possible to assert on a dedicated spy call: sinon.assert.calledWithMatch(spy.secondCall, arg1, arg2, ...);. + */ + calledWithMatch(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: TArgs): void; + /** + * Passes if spy was called once with matching arguments. + * This behaves the same way as calling both sinon.assert.calledOnce(spy) and + * sinon.assert.calledWithMatch(spy, ...). */ - calledWithMatch(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: any[]): void; + calledOnceWithMatch( + spyOrSpyCall: SinonSpy | SinonSpyCall, + ...args: TArgs + ): void; /** * Passes if spy was always called with matching arguments. * This behaves the same way as sinon.assert.alwaysCalledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). */ - alwaysCalledWithMatch(spy: SinonSpy, ...args: any[]): void; + alwaysCalledWithMatch(spy: SinonSpy, ...args: TArgs): void; /** * Passes if spy was never called with matching arguments. * This behaves the same way as sinon.assert.neverCalledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). * @param spy * @param args */ - neverCalledWithMatch(spy: SinonSpy, ...args: any[]): void; + neverCalledWithMatch(spy: SinonSpy, ...args: TArgs): void; /** * Passes if spy was called with the new operator. * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithNew(spy.secondCall, arg1, arg2, ...);. * @param spyOrSpyCall */ - calledWithNew(spyOrSpyCall: SinonSpy | SinonSpyCall): void; + calledWithNew(spyOrSpyCall: SinonSpy | SinonSpyCall): void; /** * Passes if spy threw any exception. */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall): void; /** * Passes if spy threw the given exception. * The exception is an actual object. * It’s possible to assert on a dedicated spy call: sinon.assert.threw(spy.thirdCall, exception);. */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: string): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: string): void; /** * Passes if spy threw the given exception. * The exception is a String denoting its type. * It’s possible to assert on a dedicated spy call: sinon.assert.threw(spy.thirdCall, exception);. */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: any): void; + threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: any): void; + /** * Like threw, only required for all calls to the spy. */ - alwaysThrew(spy: SinonSpy): void; + alwaysThrew(spy: SinonSpy): void; /** * Like threw, only required for all calls to the spy. */ - alwaysThrew(spy: SinonSpy, exception: string): void; + alwaysThrew(spy: SinonSpy, exception: string): void; /** * Like threw, only required for all calls to the spy. */ - alwaysThrew(spy: SinonSpy, exception: any): void; + alwaysThrew(spy: SinonSpy, exception: any): void; + /** * Uses sinon.match to test if the arguments can be considered a match. */ @@ -1469,7 +1472,9 @@ declare namespace Sinon { /** * Replaces a type with a Sinon stub if it's a function. */ - type SinonStubbedMember = T extends Function ? SinonStub : T; + type SinonStubbedMember = T extends (...args: infer TArgs) => infer TReturnValue + ? SinonStub + : T; interface SinonFake { /** @@ -1523,6 +1528,7 @@ declare namespace Sinon { clock: SinonFakeTimers; requests: SinonFakeXMLHttpRequest[]; server: SinonFakeServer; + match: SinonMatch; /** * Works exactly like sinon.spy */ @@ -1536,6 +1542,8 @@ declare namespace Sinon { */ mock: SinonMockStatic; + fake: SinonFake; + /** * * No param : Causes Sinon to replace the global setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate, process.hrtime, performance.now(when available) * and Date with a custom implementation which is bound to the returned clock object. @@ -1604,10 +1612,7 @@ declare namespace Sinon { * replacement can be any value, including spies, stubs and fakes. * This method only works on non-accessor properties, for replacing accessors, use sandbox.replaceGetter() and sandbox.replaceSetter(). */ - replace( - obj: T, - prop: TKey, - replacement: T[TKey]): T[TKey]; + replace(obj: T, prop: TKey, replacement: T[TKey]): T[TKey]; /** * Replaces getter for property on object with replacement argument. Attempts to replace an already replaced getter cause an exception. * replacement must be a Function, and can be instances of spies, stubs and fakes. @@ -1615,10 +1620,7 @@ declare namespace Sinon { * @param prop * @param replacement */ - replaceGetter( - obj: T, - prop: TKey, - replacement: () => T[TKey]): () => T[TKey]; + replaceGetter(obj: T, prop: TKey, replacement: () => T[TKey]): () => T[TKey]; /** * Replaces setter for property on object with replacement argument. Attempts to replace an already replaced setter cause an exception. * replacement must be a Function, and can be instances of spies, stubs and fakes. @@ -1629,7 +1631,8 @@ declare namespace Sinon { replaceSetter( obj: T, prop: TKey, - replacement: (val: T[TKey]) => void): (val: T[TKey]) => void; + replacement: (val: T[TKey]) => void, + ): (val: T[TKey]) => void; /** * Creates a new object with the given functions as the prototype and stubs all implemented functions. @@ -1642,18 +1645,19 @@ declare namespace Sinon { */ createStubInstance( constructor: StubbableType, - overrides?: { [K in keyof TType]?: any } + overrides?: { + [K in keyof TType]?: + | SinonStubbedMember + | (TType[K] extends (...args: any[]) => infer R ? R : TType[K]); + }, ): SinonStubbedInstance; } interface SinonApi { - fake: SinonFake; - match: SinonMatch; - spyCall(...args: any[]): SinonSpyCall; expectation: SinonExpectationStatic; clock: { - create(now: number | Date): SinonFakeTimers; + create(now: number | Date): FakeTimers.Clock; }; FakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic; @@ -1667,18 +1671,25 @@ declare namespace Sinon { */ createSandbox(config?: Partial): SinonSandbox; defaultConfig: Partial; - } - interface LegacySandbox { - sandbox: { - /** - * @deprecated Since 5.0, use `sinon.createSandbox` instead - */ - create(config?: Partial): SinonSandbox; - }; + /** + * Add a custom behavior. + * The name will be available as a function on stubs, and the chaining mechanism + * will be set up for you (e.g. no need to return anything from your function, + * its return value will be ignored). The fn will be passed the fake instance + * as its first argument, and then the user's arguments. + */ + addBehavior: (name: string, fn: (fake: SinonStub, ...userArgs: any[]) => void) => void; + + /** + * Replace the default formatter used when formatting ECMAScript object + * An example converts a basic object, such as {id: 42 }, to a string + * on a format of your choosing, such as "{ id: 42 }" + */ + setFormatter: (customFormatter: (...args: any[]) => string) => void; } - type SinonStatic = SinonSandbox & LegacySandbox & SinonApi; + type SinonStatic = SinonSandbox & SinonApi; } declare const Sinon: Sinon.SinonStatic; diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/CHANGELOG.md b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/CHANGELOG.md new file mode 100644 index 0000000000..d7d53d4f7e --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/CHANGELOG.md @@ -0,0 +1,422 @@ + +7.1.2 / 2021-05-28 +================== + + * Fix #382 by making config fields optional (#383) + * Fix #347 : Support util.promisify + +7.1.1 / 2021-05-27 +================== + + * Fix JSDoc for createClock + +7.1.0 / 2021-05-20 +================== + + * Remove Safari from Sauce Lab (ref #380) + * Bump hosted-git-info from 2.6.0 to 2.8.9 + * Bump handlebars from 4.7.6 to 4.7.7 + * Bump lodash from 4.17.19 to 4.17.21 + * Add in latest Safari and evergreen Edge + * Drop IE11 and Safari 9 + * chore: add type tests (#373) + * remove constructor types + * use globalThis to avoid conflicts + * Update yargs-parser + * Update mkdirp + * Upgrade jsdom + * Upgrade mochify to latest + * Upgrade Mocha to latest + * Bump y18n from 4.0.0 to 4.0.1 + * make config optional + * add a bunch more types + +7.0.5 / 2021-04-11 +================== + + * Fix up some clock types in JSDoc (becomes `.d.ts`) (#370) + * Fix refresh arguments forwarding (#369) + +7.0.4 / 2021-04-08 +================== + + * Fix usage with TypeScript + +7.0.3 / 2021-03-02 +================== + + * Removing the use of eval in Node.js (#331) + * Drop Node 8 + * Add docs about typings (#357) + +7.0.2 / 2021-01-18 +================== + + * Make config options optional in TypeScript defs (#354) + +7.0.1 / 2021-01-14 +================== + + * Update README section about browser use + +7.0.0 / 2021-01-12 +================== + + * Remove bundle from package. If you're loading `fake-timers` via + script tag, you'll now have to provide your own bundled version + * Add .d.ts files to package + * Revert "Add stack trace to code recursively scheduling timers" (#338) + * Remove unnecessary durations and use globals + * Support timeout.refresh in node environments + * Fix #319: Error message changed to TypeError + * Fix #319: The use of 'eval' has been removed + * Fix #304: clearTimeout clears setInterval and clearInterval clears setTimeout + * Remove config.target (#318) + + +6.0.1 / 2020-03-24 +================== + + * Support util.promisify in Node (#223) + +6.0.0 / 2020-02-04 +================== + + * Rename project to `@sinonjs/fake-timers` + +5.1.2 / 2019-12-19 +================== + + * Use global from `@sinonjs/commons` + * Fix setSystemTime affects hrtime if its called multiple times. + * Test coverage: use nyc + +5.1.1 / 2019-10-21 +================== + + * Fix global ReferenceError (#273) + +5.1.0 / 2019-10-14 +================== + + * Upgrade lolex with async versions of most calls + +5.0.1 / 2019-10-10 +================== + + * Upgrade eslint, add prettier + * Use `--no-detect-globals` to bundle and test lolex (#270) + +5.0.0 / 2019-10-07 +================== + + * Avoid installing setImmediate in unsupported environments + * fix #246: non-constructor Date() should return a string + +4.2.0 / 2019-08-04 +================== + + * Fix support for replacing the JSDOM performance field + +4.1.0 / 2019-06-04 +================== + + * Fix crash on Bash version 3 (macOS) + * Support hrtime.bigint() + * fix: count microtasks in countTimers + * Return empty arrays for performance.getEntries, other relevant methods + +4.0.1 / 2019-04-17 +================== + + * Remove sinon: added by mistake + +4.0.0 / 2019-04-17 +================== + + * Drop support for IE9 and IE10: link to supported browsers in README + * No more ExperimentalWarnings in Node environment for queueMicrotask() if it's not used in user's code + +3.1.0 / 2019-02-11 +================== + + * default timeout set to 50ms + * first implementation of requestIdleCallback and cancelIdleCallback + * fixed accidentally performance.now() -> x.now() replacement + * added queueMicrotask + +3.0.0 / 2018-10-08 +================== + + * Add countTimers method + * Disallow negative ticks (breaking API change!) + * Avoid exposing hrNow + * Fix #207 - round-off errors in `hrtime` + * Truncate sub-nanosecond values for `hrtime` + * Truncate sub-millisceond values for `Date.now()` + +v2.7.5 / 2018-09-19 +================== + + * fix: handle floating point in hrtime (#210) + * fix: reset high resolution timer on clock.reset (#209) + * Add an error when creating a clock with no Date object (#205) + +v2.7.4 / 2018-09-05 +================== + + * performance.mark related fixes for failing Safari, IE 10 and IE 11 tests + +v2.7.3 / 2018-09-05 +================== + + * Fix for #200: TypeError on performance.mark + +v2.7.2 / 2018-09-04 +================== + + * fix(setInterval): parse `timeout` arg to integer (#202) + * Upgrade insecure dependencies with npm audit fix + +v2.7.1 / 2018-07-06 +================== + * Fix performance replacement on iOS 9.3 + +v2.7.0 / 2018-05-25 +================== + + * reset clock to start + * check Performance exists before touching it + +v2.6.0 / 2018-05-16 +================== + + * Fix `reset` and document it publicly Clear microtick jobs and set now to 0 in reset (#179) + * Access Date on `_global` (#178) + +v2.5.0 / 2018-05-13 +================== + + * feat: respect loopLimit in runMicrotasks (#172) + * assign performance as a property, not as a function + +v2.4.2 / 2018-05-11 +=================== + * Upgrade Mochify to v5.6 (#162) fixed #170 + * Access `Performance` via `_global` (#168) + +v2.4.1 / 2018-05-08 +================== + + * fix: handle negative infinity timeout (#165) + +v2.4.0 / 2018-05-08 +================== + + * Add `withGlobal` export + * expose runMicrotasks + * Fix that performance.mark is undefined after timer install + +v2.3.2 / 2018-01-29 +================== + +* Add files section to package.json to avoid unnecessary package bloat #154 +* Add missing functions in default `toFake` #150 + +v2.3.1 / 2017-11-22 +================== + + * bugfix for a setTimeout() or setSystemTime() within a nextTick() call. (#145) + +v2.3.0 / 2017-11-08 +================== + + * Stops leak of (request|cancel)AnimationFrame into global scope. (#143) + * return timers on uninstall + +v2.2.0 / 2017-11-07 +================== + + * Add support for requestAnimationFrame + * fix negative timeout bug + +v2.1.3 / 2017-10-03 +================== + + * add module entry point (#133) + +v2.1.2 / 2017-07-25 +================== + + * - does not fake process.nextTick by default - added .idea folder to .gitignore - fixed documentation - added clock teardowns in tests + * overflowing the timer correctly (issue #67) + +v2.1.1 / 2017-07-19 +================== + + * support passing parameters in nextTick (fixes #122) + +v2.1.0 / 2017-07-18 +================== + + * Throw error on incorrect install use (#112) + * Add support for process.nextTick + * lolex can now attach itself to the system timers and automatically ad… (#102) + * update hrtime when an interval ticks + +v2.0.0 / 2017-07-13 +================== + + * New install() signature + * Add support for performance.now (#106) + * Fix issue with tick(): setSystemClock then throw + * Update old dependencies + * Added support to automatically increment time (#85) + * Changed internal uninstall method signature + +v1.6.0 / 2017-02-25 +=================== + + * Use common Sinon.JS eslint config + * Allow install to be called with date object + * Remove wrapper function + * Fixed typo in clock.runAll error + +v1.5.2 / 2016-11-10 +=================== + + * Upgrade mocha to latest + * Only overwrite globals when running in IE + +1.5.1 / 2016-07-26 +================== + + * Fix setInterval() behavior with string times + * Incorporate test from PR #65 + * Fix issue #59: context object required 'process' + * fixed a case where runAll was called and there are no timers (#70) + * Correct the clear{Interval|Timeout|Immediate} error message when calling `set*` for a different type of timer. + * Lots of minor changes to tooling and the build process + +v1.5.0 / 2016-05-18 +=================== + + * 1.5.0 + * Check for existence of `process` before using it + * Run to last existing timer + * Add runAll method to run timers until empty + * Turn off Sauce Labs tests for pull requests + * Add tests demonstrating that a fake Date could be created with one argument as a String since this string is in a format recognized by the Date.parse() method. + * Run test-cloud on Travis + * Add process.hrtime() + * Add bithound badge to Readme.md + * Make Travis also run tests in node 4.2 + * Update jslint, referee, sinon, browserify, mocha, mochify + * Rename src/lolex.js to src/lolex-src.js to avoid bithound ignoring it + * Add .bithoundrc + +v1.4.0 / 2015-12-11 +=================== + + * 1.4.0 + * Remove BASH syntax in lint script + * correct test descriptions to match the tests + * correct parseTime() error message so it matches behavior + * don't run test-cloud as part of npm test + * doc: full API reference + * doc: update 'Running tests' section + * doc: update 'Faking the native timers' section + * doc: remove requestAnimationFrame + * Implement clock.next() + * Run lint in CI + * Fix jslint errors + +v1.3.2 / 2015-09-22 +=================== + + * 1.3.2 + * Fix for breaking shimmed setImmediate + +v1.3.1 / 2015-08-20 +=================== + + * Remove error whos reason is no longer accurate + +v1.3.0 / 2015-08-19 +=================== + + * 1.3.0 + * Throw exception on wrong use of clearXYZ() + * Fix for Sinon.JS issue #808 :add setSystemTime() function + * Fix for Sinon.JS issue #766: clearTimeout() no longer clears Immediate/Interval and vice versa + * Update Readme.md to point to LICENSE file + * Fix error in readme about running tests + * Fix for warning about SPDX license format on npm install + +v1.2.2 / 2015-07-22 +=================== + + * 1.2.2 + * Fixing lint mistake + * Update travis to use node@0.12 + * Fix complaint about missing fake setImmediate + * Use license in package.json + +v1.2.1 / 2015-01-06 +=================== + + * New build + * Dodge JSLint... + * Up version + * Proper fix for writable globals in IE + * Make timers writable in old IEs + +v1.2.0 / 2014-12-12 +=================== + + * 1.2.0 + * Fix Sinon.JS issue 624 + * Lint the test files also + * Add .jslintrc + * Delay setImmediate if it is during tick call + * Add test case + * Test behaviour of hasOwnProperty beforehand + * Compare now() with delta + * Use undefined for defined predicate + * Put setImmediate in toFake list + * Capture clock instance for uninstall + * Restore commented out tests + * Add JSLint verification to test + * Configure Travis to run tests in node 0.10.x + * Add .editorconfig + * Fail when faking Date but not setTimeout/setInterval + +v1.1.10 / 2014-11-14 +==================== + + * 1.1.0 Fixes setImmediate problems + * Rely on `timer` initialization to null + * Timer assembly occurs at addTimer callsites + * Sort immediate timers before non-immediate + * Add createdAt to timers + * Sort timers by multiple criteria, not just callAt + * Refactor firstTimerInRange + * Rename `timeouts` property to `timers` + * addTimer is options-driven + +v1.0.0 / 2014-11-12 +=================== + + * Add built file for browsers + * Fix URL + * Don't run tests that require global.__proto__ on IE 9 and IE 10 + * Add "bundle" script to create standalone UMD bundle with browserify + * Float with new test framework versions + * Remove redundant module prefix + * Let Browserify set "global" for us + * Change test framework from Buster to Mocha and Mochify + * Make timer functions independent on `this` + * Change APIs according to Readme + * Change clock-creating interface + * Change Github paths + * Basically working extraction from Sinon.JS diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/LICENSE b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/LICENSE new file mode 100644 index 0000000000..eb84755e17 --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) 2010-2014, Christian Johansen, christian@cjohansen.no. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/README.md b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/README.md new file mode 100644 index 0000000000..81ca7b47af --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/README.md @@ -0,0 +1,366 @@ +# `@sinonjs/fake-timers` + +[![CircleCI](https://circleci.com/gh/sinonjs/fake-timers.svg?style=svg)](https://circleci.com/gh/sinonjs/fake-timers) +[![codecov](https://codecov.io/gh/sinonjs/fake-timers/branch/master/graph/badge.svg)](https://codecov.io/gh/sinonjs/fake-timers) +Contributor Covenant + +JavaScript implementation of the timer APIs; `setTimeout`, `clearTimeout`, `setImmediate`, `clearImmediate`, `setInterval`, `clearInterval`, `requestAnimationFrame`, `cancelAnimationFrame`, `requestIdleCallback`, and `cancelIdleCallback`, along with a clock instance that controls the flow of time. FakeTimers also provides a `Date` implementation that gets its time from the clock. + +In addition in browser environment `@sinonjs/fake-timers` provides a `performance` implementation that gets its time from the clock. In Node environments FakeTimers provides a `nextTick` implementation that is synchronized with the clock - and a `process.hrtime` shim that works with the clock. + +`@sinonjs/fake-timers` can be used to simulate passing time in automated tests and other +situations where you want the scheduling semantics, but don't want to actually +wait. + +`@sinonjs/fake-timers` is extracted from [Sinon.JS](https://github.com/sinonjs/sinon.js) and targets the [same runtimes](https://sinonjs.org/releases/latest/#supported-runtimes). + +## Help us get our TypeScript definitions production ready! + +In version 7 we introduced TypeScript definitions that are generated from our JSDoc. This makes importing types from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sinonjs__fake-timers/index.d.ts) superfluous, but we have just gotten started and we need your work for this to be up to the same quality. Until that happens typings from DefinitelyTyped still can be used: + +```sh +npm install -D @types/sinonjs__fake-timers +``` + +Add this to tsconfig.json + +``` +{ + "compilerOptions": { + ... + "paths": { + ... + "@sinonjs/fake-timers": ["node_modules/@types/sinonjs__fake-timers"] + } + } +} +``` + +## Installation + +`@sinonjs/fake-timers` can be used in both Node and browser environments. Installation is as easy as + +```sh +npm install @sinonjs/fake-timers +``` + +If you want to use `@sinonjs/fake-timers` in a browser you can either build your own bundle or use [Skypack](https://www.skypack.dev). + +## Usage + +To use `@sinonjs/fake-timers`, create a new clock, schedule events on it using the timer +functions and pass time using the `tick` method. + +```js +// In the browser distribution, a global `FakeTimers` is already available +var FakeTimers = require("@sinonjs/fake-timers"); +var clock = FakeTimers.createClock(); + +clock.setTimeout(function () { + console.log( + "The poblano is a mild chili pepper originating in the state of Puebla, Mexico." + ); +}, 15); + +// ... + +clock.tick(15); +``` + +Upon executing the last line, an interesting fact about the +[Poblano](https://en.wikipedia.org/wiki/Poblano) will be printed synchronously to +the screen. If you want to simulate asynchronous behavior, you have to use your +imagination when calling the various functions. + +The `next`, `runAll`, `runToFrame`, and `runToLast` methods are available to advance the clock. See the +API Reference for more details. + +### Faking the native timers + +When using `@sinonjs/fake-timers` to test timers, you will most likely want to replace the native +timers such that calling `setTimeout` actually schedules a callback with your +clock instance, not the browser's internals. + +Calling `install` with no arguments achieves this. You can call `uninstall` +later to restore things as they were again. + +```js +// In the browser distribution, a global `FakeTimers` is already available +var FakeTimers = require("@sinonjs/fake-timers"); + +var clock = FakeTimers.install(); +// Equivalent to +// var clock = FakeTimers.install(typeof global !== "undefined" ? global : window); + +setTimeout(fn, 15); // Schedules with clock.setTimeout + +clock.uninstall(); +// setTimeout is restored to the native implementation +``` + +To hijack timers in another context pass it to the `install` method. + +```js +var FakeTimers = require("@sinonjs/fake-timers"); +var context = { + setTimeout: setTimeout, // By default context.setTimeout uses the global setTimeout +}; +var clock = FakeTimers.withGlobal(context).install(); + +context.setTimeout(fn, 15); // Schedules with clock.setTimeout + +clock.uninstall(); +// context.setTimeout is restored to the original implementation +``` + +Usually you want to install the timers onto the global object, so call `install` +without arguments. + +#### Automatically incrementing mocked time + +FakeTimers supports the possibility to attach the faked timers to any change +in the real system time. This means that there is no need to `tick()` the +clock in a situation where you won't know **when** to call `tick()`. + +Please note that this is achieved using the original setImmediate() API at a certain +configurable interval `config.advanceTimeDelta` (default: 20ms). Meaning time would +be incremented every 20ms, not in real time. + +An example would be: + +```js +var FakeTimers = require("@sinonjs/fake-timers"); +var clock = FakeTimers.install({ + shouldAdvanceTime: true, + advanceTimeDelta: 40, +}); + +setTimeout(() => { + console.log("this just timed out"); //executed after 40ms +}, 30); + +setImmediate(() => { + console.log("not so immediate"); //executed after 40ms +}); + +setTimeout(() => { + console.log("this timed out after"); //executed after 80ms + clock.uninstall(); +}, 50); +``` + +## API Reference + +### `var clock = FakeTimers.createClock([now[, loopLimit]])` + +Creates a clock. The default +[epoch](https://en.wikipedia.org/wiki/Epoch_%28reference_date%29) is `0`. + +The `now` argument may be a number (in milliseconds) or a Date object. + +The `loopLimit` argument sets the maximum number of timers that will be run when calling `runAll()` before assuming that we have an infinite loop and throwing an error. The default is `1000`. + +### `var clock = FakeTimers.install([config])` + +Installs FakeTimers using the specified config (otherwise with epoch `0` on the global scope). The following configuration options are available + +| Parameter | Type | Default | Description | +| -------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `config.now` | Number/Date | 0 | installs FakeTimers with the specified unix epoch | +| `config.toFake` | String[] | ["setTimeout", "clearTimeout", "setImmediate", "clearImmediate","setInterval", "clearInterval", "Date", "requestAnimationFrame", "cancelAnimationFrame", "requestIdleCallback", "cancelIdleCallback", "hrtime"] | an array with explicit function names to hijack. _When not set, FakeTimers will automatically fake all methods **except** `nextTick`_ e.g., `FakeTimers.install({ toFake: ["setTimeout","nextTick"]})` will fake only `setTimeout` and `nextTick` | +| `config.loopLimit` | Number | 1000 | the maximum number of timers that will be run when calling runAll() | +| `config.shouldAdvanceTime` | Boolean | false | tells FakeTimers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by 20ms for every 20ms change in the real system time) | +| `config.advanceTimeDelta` | Number | 20 | relevant only when using with `shouldAdvanceTime: true`. increment mocked time by `advanceTimeDelta` ms every `advanceTimeDelta` ms change in the real system time. | + +### `var id = clock.setTimeout(callback, timeout)` + +Schedules the callback to be fired once `timeout` milliseconds have ticked by. + +In Node.js `setTimeout` returns a timer object. FakeTimers will do the same, however +its `ref()` and `unref()` methods have no effect. + +In browsers a timer ID is returned. + +### `clock.clearTimeout(id)` + +Clears the timer given the ID or timer object, as long as it was created using +`setTimeout`. + +### `var id = clock.setInterval(callback, timeout)` + +Schedules the callback to be fired every time `timeout` milliseconds have ticked +by. + +In Node.js `setInterval` returns a timer object. FakeTimers will do the same, however +its `ref()` and `unref()` methods have no effect. + +In browsers a timer ID is returned. + +### `clock.clearInterval(id)` + +Clears the timer given the ID or timer object, as long as it was created using +`setInterval`. + +### `var id = clock.setImmediate(callback)` + +Schedules the callback to be fired once `0` milliseconds have ticked by. Note +that you'll still have to call `clock.tick()` for the callback to fire. If +called during a tick the callback won't fire until `1` millisecond has ticked +by. + +In Node.js `setImmediate` returns a timer object. FakeTimers will do the same, +however its `ref()` and `unref()` methods have no effect. + +In browsers a timer ID is returned. + +### `clock.clearImmediate(id)` + +Clears the timer given the ID or timer object, as long as it was created using +`setImmediate`. + +### `clock.requestAnimationFrame(callback)` + +Schedules the callback to be fired on the next animation frame, which runs every +16 ticks. Returns an `id` which can be used to cancel the callback. This is +available in both browser & node environments. + +### `clock.cancelAnimationFrame(id)` + +Cancels the callback scheduled by the provided id. + +### `clock.requestIdleCallback(callback[, timeout])` + +Queued the callback to be fired during idle periods to perform background and low priority work on the main event loop. Callbacks which have a timeout option will be fired no later than time in milliseconds. Returns an `id` which can be used to cancel the callback. + +### `clock.cancelIdleCallback(id)` + +Cancels the callback scheduled by the provided id. + +### `clock.countTimers()` + +Returns the number of waiting timers. This can be used to assert that a test +finishes without leaking any timers. + +### `clock.hrtime(prevTime?)` + +Only available in Node.js, mimicks process.hrtime(). + +### `clock.nextTick(callback)` + +Only available in Node.js, mimics `process.nextTick` to enable completely synchronous testing flows. + +### `clock.performance.now()` + +Only available in browser environments, mimicks performance.now(). + +### `clock.tick(time)` / `await clock.tickAsync(time)` + +Advance the clock, firing callbacks if necessary. `time` may be the number of +milliseconds to advance the clock by or a human-readable string. Valid string +formats are `"08"` for eight seconds, `"01:00"` for one minute and `"02:34:10"` +for two hours, 34 minutes and ten seconds. + +The `tickAsync()` will also break the event loop, allowing any scheduled promise +callbacks to execute _before_ running the timers. + +### `clock.next()` / `await clock.nextAsync()` + +Advances the clock to the the moment of the first scheduled timer, firing it. + +The `nextAsync()` will also break the event loop, allowing any scheduled promise +callbacks to execute _before_ running the timers. + +### `clock.reset()` + +Removes all timers and ticks without firing them, and sets `now` to `config.now` +that was provided to `FakeTimers.install` or to `0` if `config.now` was not provided. +Useful to reset the state of the clock without having to `uninstall` and `install` it. + +### `clock.runAll()` / `await clock.runAllAsync()` + +This runs all pending timers until there are none remaining. If new timers are added while it is executing they will be run as well. + +This makes it easier to run asynchronous tests to completion without worrying about the number of timers they use, or the delays in those timers. + +It runs a maximum of `loopLimit` times after which it assumes there is an infinite loop of timers and throws an error. + +The `runAllAsync()` will also break the event loop, allowing any scheduled promise +callbacks to execute _before_ running the timers. + +### `clock.runMicrotasks()` + +This runs all pending microtasks scheduled with `nextTick` but none of the timers and is mostly useful for libraries using FakeTimers underneath and for running `nextTick` items without any timers. + +### `clock.runToFrame()` + +Advances the clock to the next frame, firing all scheduled animation frame callbacks, +if any, for that frame as well as any other timers scheduled along the way. + +### `clock.runToLast()` / `await clock.runToLastAsync()` + +This takes note of the last scheduled timer when it is run, and advances the +clock to that time firing callbacks as necessary. + +If new timers are added while it is executing they will be run only if they +would occur before this time. + +This is useful when you want to run a test to completion, but the test recursively +sets timers that would cause `runAll` to trigger an infinite loop warning. + +The `runToLastAsync()` will also break the event loop, allowing any scheduled promise +callbacks to execute _before_ running the timers. + +### `clock.setSystemTime([now])` + +This simulates a user changing the system clock while your program is running. +It affects the current time but it does not in itself cause e.g. timers to fire; +they will fire exactly as they would have done without the call to +setSystemTime(). + +### `clock.uninstall()` + +Restores the original methods of the native timers or the methods on the object +that was passed to `FakeTimers.withGlobal` + +### `Date` + +Implements the `Date` object but using the clock to provide the correct time. + +### `Performance` + +Implements the `now` method of the [`Performance`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) object but using the clock to provide the correct time. Only available in environments that support the Performance object (browsers mostly). + +### `FakeTimers.withGlobal` + +In order to support creating clocks based on separate or sandboxed environments (such as JSDOM), FakeTimers exports a factory method which takes single argument `global`, which it inspects to figure out what to mock and what features to support. When invoking this function with a global, you will get back an object with `timers`, `createClock` and `install` - same as the regular FakeTimers exports only based on the passed in global instead of the global environment. + +## Running tests + +FakeTimers has a comprehensive test suite. If you're thinking of contributing bug +fixes or suggesting new features, you need to make sure you have not broken any +tests. You are also expected to add tests for any new behavior. + +### On node: + +```sh +npm test +``` + +Or, if you prefer more verbose output: + +``` +$(npm bin)/mocha ./test/fake-timers-test.js +``` + +### In the browser + +[Mochify](https://github.com/mantoni/mochify.js) is used to run the tests in +PhantomJS. Make sure you have `phantomjs` installed. Then: + +```sh +npm test-headless +``` + +## License + +BSD 3-clause "New" or "Revised" License (see LICENSE file) diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/package.json b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/package.json new file mode 100644 index 0000000000..b8cb7cc1b1 --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/package.json @@ -0,0 +1,84 @@ +{ + "name": "@sinonjs/fake-timers", + "description": "Fake JavaScript timers", + "version": "7.1.2", + "homepage": "https://github.com/sinonjs/fake-timers", + "author": "Christian Johansen", + "repository": { + "type": "git", + "url": "https://github.com/sinonjs/fake-timers.git" + }, + "bugs": { + "mail": "christian@cjohansen.no", + "url": "https://github.com/sinonjs/fake-timers/issues" + }, + "license": "BSD-3-Clause", + "scripts": { + "build": "rm -rf types && tsc", + "lint": "eslint .", + "test-node": "mocha test/ integration-test/ -R dot --check-leaks", + "test-headless": "mochify --no-detect-globals --timeout=10000", + "test-check-coverage": "npm run test-coverage && nyc check-coverage", + "test-cloud": "mochify --wd --no-detect-globals --timeout=10000", + "test-coverage": "nyc --all --reporter text --reporter html --reporter lcovonly npm run test-node", + "test-types": "tsd && tsc --noEmit test/check-types.ts", + "test": "npm run test-node && npm run test-headless", + "prettier:check": "prettier --check '**/*.{js,css,md,ts}'", + "prettier:write": "prettier --write '**/*.{js,css,md,ts}'", + "prepublishOnly": "npm run build", + "preversion": "./scripts/preversion.sh", + "version": "./scripts/version.sh", + "postversion": "./scripts/postversion.sh" + }, + "lint-staged": { + "*.{js,css,md}": "prettier --check", + "*.js": "eslint" + }, + "files": [ + "src/", + "types" + ], + "devDependencies": { + "@sinonjs/referee-sinon": "6.0.1", + "eslint": "6.8.0", + "eslint-config-prettier": "6.10.0", + "eslint-config-sinon": "3.0.1", + "eslint-plugin-ie11": "1.0.0", + "eslint-plugin-mocha": "6.2.2", + "eslint-plugin-prettier": "3.1.1", + "husky": "4.2.1", + "jsdom": "16.5.2", + "lint-staged": "10.0.7", + "mocha": "8.3.2", + "mochify": "7.0.0", + "nyc": "14.1.1", + "prettier": "2.2.1", + "tsd": "0.14.0", + "typescript": "4.1.3" + }, + "main": "./src/fake-timers-src.js", + "types": "./types/fake-timers-src.d.ts", + "dependencies": { + "@sinonjs/commons": "^1.7.0" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint" + } + }, + "nyc": { + "branches": 85, + "lines": 92, + "functions": 92, + "statements": 92, + "exclude": [ + "**/*-test.js", + "coverage/**", + "types/**", + "fake-timers.js" + ] + }, + "tsd": { + "directory": "test" + } +} \ No newline at end of file diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js new file mode 100644 index 0000000000..4257e91a12 --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js @@ -0,0 +1,1409 @@ +"use strict"; + +var globalObject = require("@sinonjs/commons").global; + +/** + * @typedef {object} Clock + * @property {number} now + * @property {any} timeouts + * @property {typeof globalThis.Date} Date + * @property {number} loopLimit + * @property {(func: Function, timeout: number) => number} requestIdleCallback + * @property {(timerId: number) => void} cancelIdleCallback + * @property {setTimeout} setTimeout + * @property {clearTimeout} clearTimeout + * @property {(func: Function, ...args: any[]) => void} nextTick + * @property {queueMicrotask} queueMicrotask + * @property {setInterval} setInterval + * @property {clearInterval} clearInterval + * @property {(func: (...args: any[]) => void, ...args: any[]) => NodeTimer} setImmediate + * @property {(timerId: NodeTimer) => void} clearImmediate + * @property {() => number} countTimers + * @property {(func: (timer: number) => void) => number} requestAnimationFrame + * @property {(timerId: number) => void} cancelAnimationFrame + * @property {() => void} runMicrotasks + * @property {(tickValue: string | number) => number} tick + * @property {(tickValue: string | number) => Promise} tickAsync + * @property {() => number} next + * @property {() => Promise} nextAsync + * @property {() => number} runAll + * @property {() => number} runToFrame + * @property {() => Promise} runAllAsync + * @property {() => number} runToLast + * @property {() => Promise} runToLastAsync + * @property {() => void} reset + * @property {(systemTime: number | Date) => void} setSystemTime + * @property {({now(): number})} performance + * @property {(prev: any) => number[]} hrTime + * @property {() => void} uninstall Uninstall the clock. + * @property {any} methods + */ + +/** + * Configuration object for the `install` method. + * + * @typedef {object} Config + * @property {number|Date} [now] a number (in milliseconds) or a Date object (default epoch) + * @property {string[]} [toFake] names of the methods that should be faked. + * @property {number} [loopLimit] the maximum number of timers that will be run when calling runAll() + * @property {boolean} [shouldAdvanceTime] tells FakeTimers to increment mocked time automatically (default false) + * @property {number} [advanceTimeDelta] increment mocked time every <> ms (default: 20ms) + */ + +/** + * @typedef {object} NodeTimer + * @property {() => boolean} hasRef + * @property {() => any} ref + * @property {() => any} unref + */ + +/* eslint-disable complexity */ + +/** + * Mocks available features in the specified global namespace. + * + * @param {*} _global Namespace to mock (e.g. `window`) + */ +function withGlobal(_global) { + var userAgent = _global.navigator && _global.navigator.userAgent; + var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; + var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint + var NOOP = function () { + return undefined; + }; + var NOOP_ARRAY = function () { + return []; + }; + var timeoutResult = _global.setTimeout(NOOP, 0); + var addTimerReturnsObject = typeof timeoutResult === "object"; + var hrtimePresent = + _global.process && typeof _global.process.hrtime === "function"; + var hrtimeBigintPresent = + hrtimePresent && typeof _global.process.hrtime.bigint === "function"; + var nextTickPresent = + _global.process && typeof _global.process.nextTick === "function"; + var utilPromisify = _global.process && require("util").promisify; + var performancePresent = + _global.performance && typeof _global.performance.now === "function"; + var hasPerformancePrototype = + _global.Performance && + (typeof _global.Performance).match(/^(function|object)$/); + var queueMicrotaskPresent = _global.hasOwnProperty("queueMicrotask"); + var requestAnimationFramePresent = + _global.requestAnimationFrame && + typeof _global.requestAnimationFrame === "function"; + var cancelAnimationFramePresent = + _global.cancelAnimationFrame && + typeof _global.cancelAnimationFrame === "function"; + var requestIdleCallbackPresent = + _global.requestIdleCallback && + typeof _global.requestIdleCallback === "function"; + var cancelIdleCallbackPresent = + _global.cancelIdleCallback && + typeof _global.cancelIdleCallback === "function"; + var setImmediatePresent = + _global.setImmediate && typeof _global.setImmediate === "function"; + + // Make properties writable in IE, as per + // https://www.adequatelygood.com/Replacing-setTimeout-Globally.html + /* eslint-disable no-self-assign */ + if (isRunningInIE) { + _global.setTimeout = _global.setTimeout; + _global.clearTimeout = _global.clearTimeout; + _global.setInterval = _global.setInterval; + _global.clearInterval = _global.clearInterval; + _global.Date = _global.Date; + } + + // setImmediate is not a standard function + // avoid adding the prop to the window object if not present + if (setImmediatePresent) { + _global.setImmediate = _global.setImmediate; + _global.clearImmediate = _global.clearImmediate; + } + /* eslint-enable no-self-assign */ + + _global.clearTimeout(timeoutResult); + + var NativeDate = _global.Date; + var uniqueTimerId = 1; + + function isNumberFinite(num) { + if (Number.isFinite) { + return Number.isFinite(num); + } + + return isFinite(num); + } + + /** + * Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into + * number of milliseconds. This is used to support human-readable strings passed + * to clock.tick() + */ + function parseTime(str) { + if (!str) { + return 0; + } + + var strings = str.split(":"); + var l = strings.length; + var i = l; + var ms = 0; + var parsed; + + if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) { + throw new Error( + "tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits" + ); + } + + while (i--) { + parsed = parseInt(strings[i], 10); + + if (parsed >= 60) { + throw new Error("Invalid time " + str); + } + + ms += parsed * Math.pow(60, l - i - 1); + } + + return ms * 1000; + } + + /** + * Get the decimal part of the millisecond value as nanoseconds + * + * @param {number} msFloat the number of milliseconds + * @returns {number} an integer number of nanoseconds in the range [0,1e6) + * + * Example: nanoRemainer(123.456789) -> 456789 + */ + function nanoRemainder(msFloat) { + var modulo = 1e6; + var remainder = (msFloat * 1e6) % modulo; + var positiveRemainder = remainder < 0 ? remainder + modulo : remainder; + + return Math.floor(positiveRemainder); + } + + /** + * Used to grok the `now` parameter to createClock. + * @param {Date|number} epoch the system time + */ + function getEpoch(epoch) { + if (!epoch) { + return 0; + } + if (typeof epoch.getTime === "function") { + return epoch.getTime(); + } + if (typeof epoch === "number") { + return epoch; + } + throw new TypeError("now should be milliseconds since UNIX epoch"); + } + + function inRange(from, to, timer) { + return timer && timer.callAt >= from && timer.callAt <= to; + } + + function mirrorDateProperties(target, source) { + var prop; + for (prop in source) { + if (source.hasOwnProperty(prop)) { + target[prop] = source[prop]; + } + } + + // set special now implementation + if (source.now) { + target.now = function now() { + return target.clock.now; + }; + } else { + delete target.now; + } + + // set special toSource implementation + if (source.toSource) { + target.toSource = function toSource() { + return source.toSource(); + }; + } else { + delete target.toSource; + } + + // set special toString implementation + target.toString = function toString() { + return source.toString(); + }; + + target.prototype = source.prototype; + target.parse = source.parse; + target.UTC = source.UTC; + target.prototype.toUTCString = source.prototype.toUTCString; + + return target; + } + + function createDate() { + function ClockDate(year, month, date, hour, minute, second, ms) { + // the Date constructor called as a function, ref Ecma-262 Edition 5.1, section 15.9.2. + // This remains so in the 10th edition of 2019 as well. + if (!(this instanceof ClockDate)) { + return new NativeDate(ClockDate.clock.now).toString(); + } + + // if Date is called as a constructor with 'new' keyword + // Defensive and verbose to avoid potential harm in passing + // explicit undefined when user does not pass argument + switch (arguments.length) { + case 0: + return new NativeDate(ClockDate.clock.now); + case 1: + return new NativeDate(year); + case 2: + return new NativeDate(year, month); + case 3: + return new NativeDate(year, month, date); + case 4: + return new NativeDate(year, month, date, hour); + case 5: + return new NativeDate(year, month, date, hour, minute); + case 6: + return new NativeDate( + year, + month, + date, + hour, + minute, + second + ); + default: + return new NativeDate( + year, + month, + date, + hour, + minute, + second, + ms + ); + } + } + + return mirrorDateProperties(ClockDate, NativeDate); + } + + function enqueueJob(clock, job) { + // enqueues a microtick-deferred task - ecma262/#sec-enqueuejob + if (!clock.jobs) { + clock.jobs = []; + } + clock.jobs.push(job); + } + + function runJobs(clock) { + // runs all microtick-deferred tasks - ecma262/#sec-runjobs + if (!clock.jobs) { + return; + } + for (var i = 0; i < clock.jobs.length; i++) { + var job = clock.jobs[i]; + job.func.apply(null, job.args); + if (clock.loopLimit && i > clock.loopLimit) { + throw new Error( + "Aborting after running " + + clock.loopLimit + + " timers, assuming an infinite loop!" + ); + } + } + clock.jobs = []; + } + + function addTimer(clock, timer) { + if (timer.func === undefined) { + throw new Error("Callback must be provided to timer calls"); + } + + if (addTimerReturnsObject) { + // Node.js environment + if (typeof timer.func !== "function") { + throw new TypeError( + "[ERR_INVALID_CALLBACK]: Callback must be a function. Received " + + timer.func + + " of type " + + typeof timer.func + ); + } + } + + timer.type = timer.immediate ? "Immediate" : "Timeout"; + + if (timer.hasOwnProperty("delay")) { + if (typeof timer.delay !== "number") { + timer.delay = parseInt(timer.delay, 10); + } + + if (!isNumberFinite(timer.delay)) { + timer.delay = 0; + } + timer.delay = timer.delay > maxTimeout ? 1 : timer.delay; + timer.delay = Math.max(0, timer.delay); + } + + if (timer.hasOwnProperty("interval")) { + timer.type = "Interval"; + timer.interval = timer.interval > maxTimeout ? 1 : timer.interval; + } + + if (timer.hasOwnProperty("animation")) { + timer.type = "AnimationFrame"; + timer.animation = true; + } + + if (!clock.timers) { + clock.timers = {}; + } + + timer.id = uniqueTimerId++; + timer.createdAt = clock.now; + timer.callAt = + clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0)); + + clock.timers[timer.id] = timer; + + if (addTimerReturnsObject) { + var res = { + id: timer.id, + ref: function () { + return res; + }, + unref: function () { + return res; + }, + refresh: function () { + clearTimeout(timer.id); + var args = [timer.func, timer.delay].concat(timer.args); + return setTimeout.apply(null, args); + }, + }; + return res; + } + + return timer.id; + } + + /* eslint consistent-return: "off" */ + function compareTimers(a, b) { + // Sort first by absolute timing + if (a.callAt < b.callAt) { + return -1; + } + if (a.callAt > b.callAt) { + return 1; + } + + // Sort next by immediate, immediate timers take precedence + if (a.immediate && !b.immediate) { + return -1; + } + if (!a.immediate && b.immediate) { + return 1; + } + + // Sort next by creation time, earlier-created timers take precedence + if (a.createdAt < b.createdAt) { + return -1; + } + if (a.createdAt > b.createdAt) { + return 1; + } + + // Sort next by id, lower-id timers take precedence + if (a.id < b.id) { + return -1; + } + if (a.id > b.id) { + return 1; + } + + // As timer ids are unique, no fallback `0` is necessary + } + + function firstTimerInRange(clock, from, to) { + var timers = clock.timers; + var timer = null; + var id, isInRange; + + for (id in timers) { + if (timers.hasOwnProperty(id)) { + isInRange = inRange(from, to, timers[id]); + + if ( + isInRange && + (!timer || compareTimers(timer, timers[id]) === 1) + ) { + timer = timers[id]; + } + } + } + + return timer; + } + + function firstTimer(clock) { + var timers = clock.timers; + var timer = null; + var id; + + for (id in timers) { + if (timers.hasOwnProperty(id)) { + if (!timer || compareTimers(timer, timers[id]) === 1) { + timer = timers[id]; + } + } + } + + return timer; + } + + function lastTimer(clock) { + var timers = clock.timers; + var timer = null; + var id; + + for (id in timers) { + if (timers.hasOwnProperty(id)) { + if (!timer || compareTimers(timer, timers[id]) === -1) { + timer = timers[id]; + } + } + } + + return timer; + } + + function callTimer(clock, timer) { + if (typeof timer.interval === "number") { + clock.timers[timer.id].callAt += timer.interval; + } else { + delete clock.timers[timer.id]; + } + + if (typeof timer.func === "function") { + timer.func.apply(null, timer.args); + } else { + /* eslint no-eval: "off" */ + var eval2 = eval; + (function () { + eval2(timer.func); + })(); + } + } + + function clearTimer(clock, timerId, ttype) { + if (!timerId) { + // null appears to be allowed in most browsers, and appears to be + // relied upon by some libraries, like Bootstrap carousel + return; + } + + if (!clock.timers) { + clock.timers = {}; + } + + // in Node, timerId is an object with .ref()/.unref(), and + // its .id field is the actual timer id. + var id = typeof timerId === "object" ? timerId.id : timerId; + + if (clock.timers.hasOwnProperty(id)) { + // check that the ID matches a timer of the correct type + var timer = clock.timers[id]; + if ( + timer.type === ttype || + (timer.type === "Timeout" && ttype === "Interval") || + (timer.type === "Interval" && ttype === "Timeout") + ) { + delete clock.timers[id]; + } else { + var clear = + ttype === "AnimationFrame" + ? "cancelAnimationFrame" + : "clear" + ttype; + var schedule = + timer.type === "AnimationFrame" + ? "requestAnimationFrame" + : "set" + timer.type; + throw new Error( + "Cannot clear timer: timer created with " + + schedule + + "() but cleared with " + + clear + + "()" + ); + } + } + } + + function uninstall(clock, config) { + var method, i, l; + var installedHrTime = "_hrtime"; + var installedNextTick = "_nextTick"; + + for (i = 0, l = clock.methods.length; i < l; i++) { + method = clock.methods[i]; + if (method === "hrtime" && _global.process) { + _global.process.hrtime = clock[installedHrTime]; + } else if (method === "nextTick" && _global.process) { + _global.process.nextTick = clock[installedNextTick]; + } else if (method === "performance") { + var originalPerfDescriptor = Object.getOwnPropertyDescriptor( + clock, + "_" + method + ); + if ( + originalPerfDescriptor && + originalPerfDescriptor.get && + !originalPerfDescriptor.set + ) { + Object.defineProperty( + _global, + method, + originalPerfDescriptor + ); + } else if (originalPerfDescriptor.configurable) { + _global[method] = clock["_" + method]; + } + } else { + if (_global[method] && _global[method].hadOwnProperty) { + _global[method] = clock["_" + method]; + if ( + method === "clearInterval" && + config.shouldAdvanceTime === true + ) { + _global[method](clock.attachedInterval); + } + } else { + try { + delete _global[method]; + } catch (ignore) { + /* eslint no-empty: "off" */ + } + } + } + } + + // Prevent multiple executions which will completely remove these props + clock.methods = []; + + // return pending timers, to enable checking what timers remained on uninstall + if (!clock.timers) { + return []; + } + return Object.keys(clock.timers).map(function mapper(key) { + return clock.timers[key]; + }); + } + + function hijackMethod(target, method, clock) { + clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call( + target, + method + ); + clock["_" + method] = target[method]; + + if (method === "Date") { + var date = mirrorDateProperties(clock[method], target[method]); + target[method] = date; + } else if (method === "performance") { + var originalPerfDescriptor = Object.getOwnPropertyDescriptor( + target, + method + ); + // JSDOM has a read only performance field so we have to save/copy it differently + if ( + originalPerfDescriptor && + originalPerfDescriptor.get && + !originalPerfDescriptor.set + ) { + Object.defineProperty( + clock, + "_" + method, + originalPerfDescriptor + ); + + var perfDescriptor = Object.getOwnPropertyDescriptor( + clock, + method + ); + Object.defineProperty(target, method, perfDescriptor); + } else { + target[method] = clock[method]; + } + } else { + target[method] = function () { + return clock[method].apply(clock, arguments); + }; + + Object.defineProperties( + target[method], + Object.getOwnPropertyDescriptors(clock[method]) + ); + } + + target[method].clock = clock; + } + + function doIntervalTick(clock, advanceTimeDelta) { + clock.tick(advanceTimeDelta); + } + + /** + * @typedef {object} Timers + * @property {setTimeout} setTimeout + * @property {clearTimeout} clearTimeout + * @property {setInterval} setInterval + * @property {clearInterval} clearInterval + * @property {typeof globalThis.Date} Date + * @property {((fn: (...args: any[]) => void, ...args: any[]) => NodeTimer)=} setImmediate + * @property {((id: NodeTimer) => void)=} clearImmediate + * @property {((time?: [number, number]) => [number, number])=} hrtime + * @property {((fn: Function, ...args: any[]) => void)=} nextTick + * @property {({now(): number})=} performance + * @property {((fn: (timer: number) => void) => number)=} requestAnimationFrame + * @property {boolean=} queueMicrotask + * @property {((id: number) => void)=} cancelAnimationFrame + * @property {((fn: (deadline: any) => void, options?: any) => number)=} requestIdleCallback + * @property {((id: number) => void)=} cancelIdleCallback + */ + + /** @type {Timers} */ + var timers = { + setTimeout: _global.setTimeout, + clearTimeout: _global.clearTimeout, + setInterval: _global.setInterval, + clearInterval: _global.clearInterval, + Date: _global.Date, + }; + + if (setImmediatePresent) { + timers.setImmediate = _global.setImmediate; + timers.clearImmediate = _global.clearImmediate; + } + + if (hrtimePresent) { + timers.hrtime = _global.process.hrtime; + } + + if (nextTickPresent) { + timers.nextTick = _global.process.nextTick; + } + + if (performancePresent) { + timers.performance = _global.performance; + } + + if (requestAnimationFramePresent) { + timers.requestAnimationFrame = _global.requestAnimationFrame; + } + + if (queueMicrotaskPresent) { + timers.queueMicrotask = true; + } + + if (cancelAnimationFramePresent) { + timers.cancelAnimationFrame = _global.cancelAnimationFrame; + } + + if (requestIdleCallbackPresent) { + timers.requestIdleCallback = _global.requestIdleCallback; + } + + if (cancelIdleCallbackPresent) { + timers.cancelIdleCallback = _global.cancelIdleCallback; + } + + var originalSetTimeout = _global.setImmediate || _global.setTimeout; + + /** + * @param {Date|number} [start] the system time - non-integer values are floored + * @param {number} [loopLimit] maximum number of timers that will be run when calling runAll() + * @returns {Clock} + */ + function createClock(start, loopLimit) { + // eslint-disable-next-line no-param-reassign + start = Math.floor(getEpoch(start)); + // eslint-disable-next-line no-param-reassign + loopLimit = loopLimit || 1000; + var nanos = 0; + var adjustedSystemTime = [0, 0]; // [millis, nanoremainder] + + if (NativeDate === undefined) { + throw new Error( + "The global scope doesn't have a `Date` object" + + " (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)" + ); + } + + var clock = { + now: start, + timeouts: {}, + Date: createDate(), + loopLimit: loopLimit, + }; + + clock.Date.clock = clock; + + function getTimeToNextFrame() { + return 16 - ((clock.now - start) % 16); + } + + function hrtime(prev) { + var millisSinceStart = clock.now - adjustedSystemTime[0] - start; + var secsSinceStart = Math.floor(millisSinceStart / 1000); + var remainderInNanos = + (millisSinceStart - secsSinceStart * 1e3) * 1e6 + + nanos - + adjustedSystemTime[1]; + + if (Array.isArray(prev)) { + if (prev[1] > 1e9) { + throw new TypeError( + "Number of nanoseconds can't exceed a billion" + ); + } + + var oldSecs = prev[0]; + var nanoDiff = remainderInNanos - prev[1]; + var secDiff = secsSinceStart - oldSecs; + + if (nanoDiff < 0) { + nanoDiff += 1e9; + secDiff -= 1; + } + + return [secDiff, nanoDiff]; + } + return [secsSinceStart, remainderInNanos]; + } + + if (hrtimeBigintPresent) { + hrtime.bigint = function () { + var parts = hrtime(); + return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]); // eslint-disable-line + }; + } + + clock.requestIdleCallback = function requestIdleCallback( + func, + timeout + ) { + var timeToNextIdlePeriod = 0; + + if (clock.countTimers() > 0) { + timeToNextIdlePeriod = 50; // const for now + } + + var result = addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 2), + delay: + typeof timeout === "undefined" + ? timeToNextIdlePeriod + : Math.min(timeout, timeToNextIdlePeriod), + }); + + return result.id || result; + }; + + clock.cancelIdleCallback = function cancelIdleCallback(timerId) { + return clearTimer(clock, timerId, "Timeout"); + }; + + clock.setTimeout = function setTimeout(func, timeout) { + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 2), + delay: timeout, + }); + }; + if (typeof _global.Promise !== "undefined" && utilPromisify) { + clock.setTimeout[ + utilPromisify.custom + ] = function promisifiedSetTimeout(timeout, arg) { + return new _global.Promise(function setTimeoutExecutor( + resolve + ) { + addTimer(clock, { + func: resolve, + args: [arg], + delay: timeout, + }); + }); + }; + } + + clock.clearTimeout = function clearTimeout(timerId) { + return clearTimer(clock, timerId, "Timeout"); + }; + + clock.nextTick = function nextTick(func) { + return enqueueJob(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 1), + }); + }; + + clock.queueMicrotask = function queueMicrotask(func) { + return clock.nextTick(func); // explicitly drop additional arguments + }; + + clock.setInterval = function setInterval(func, timeout) { + // eslint-disable-next-line no-param-reassign + timeout = parseInt(timeout, 10); + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 2), + delay: timeout, + interval: timeout, + }); + }; + + clock.clearInterval = function clearInterval(timerId) { + return clearTimer(clock, timerId, "Interval"); + }; + + if (setImmediatePresent) { + clock.setImmediate = function setImmediate(func) { + return addTimer(clock, { + func: func, + args: Array.prototype.slice.call(arguments, 1), + immediate: true, + }); + }; + + if (typeof _global.Promise !== "undefined" && utilPromisify) { + clock.setImmediate[ + utilPromisify.custom + ] = function promisifiedSetImmediate(arg) { + return new _global.Promise(function setImmediateExecutor( + resolve + ) { + addTimer(clock, { + func: resolve, + args: [arg], + immediate: true, + }); + }); + }; + } + + clock.clearImmediate = function clearImmediate(timerId) { + return clearTimer(clock, timerId, "Immediate"); + }; + } + + clock.countTimers = function countTimers() { + return ( + Object.keys(clock.timers || {}).length + + (clock.jobs || []).length + ); + }; + + clock.requestAnimationFrame = function requestAnimationFrame(func) { + var result = addTimer(clock, { + func: func, + delay: getTimeToNextFrame(), + args: [clock.now + getTimeToNextFrame()], + animation: true, + }); + + return result.id || result; + }; + + clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) { + return clearTimer(clock, timerId, "AnimationFrame"); + }; + + clock.runMicrotasks = function runMicrotasks() { + runJobs(clock); + }; + + function doTick(tickValue, isAsync, resolve, reject) { + var msFloat = + typeof tickValue === "number" + ? tickValue + : parseTime(tickValue); + var ms = Math.floor(msFloat); + var remainder = nanoRemainder(msFloat); + var nanosTotal = nanos + remainder; + var tickTo = clock.now + ms; + + if (msFloat < 0) { + throw new TypeError("Negative ticks are not supported"); + } + + // adjust for positive overflow + if (nanosTotal >= 1e6) { + tickTo += 1; + nanosTotal -= 1e6; + } + + nanos = nanosTotal; + var tickFrom = clock.now; + var previous = clock.now; + var timer, + firstException, + oldNow, + nextPromiseTick, + compensationCheck, + postTimerCall; + + clock.duringTick = true; + + // perform microtasks + oldNow = clock.now; + runJobs(clock); + if (oldNow !== clock.now) { + // compensate for any setSystemTime() call during microtask callback + tickFrom += clock.now - oldNow; + tickTo += clock.now - oldNow; + } + + function doTickInner() { + // perform each timer in the requested range + timer = firstTimerInRange(clock, tickFrom, tickTo); + // eslint-disable-next-line no-unmodified-loop-condition + while (timer && tickFrom <= tickTo) { + if (clock.timers[timer.id]) { + tickFrom = timer.callAt; + clock.now = timer.callAt; + oldNow = clock.now; + try { + runJobs(clock); + callTimer(clock, timer); + } catch (e) { + firstException = firstException || e; + } + + if (isAsync) { + // finish up after native setImmediate callback to allow + // all native es6 promises to process their callbacks after + // each timer fires. + originalSetTimeout(nextPromiseTick); + return; + } + + compensationCheck(); + } + + postTimerCall(); + } + + // perform process.nextTick()s again + oldNow = clock.now; + runJobs(clock); + if (oldNow !== clock.now) { + // compensate for any setSystemTime() call during process.nextTick() callback + tickFrom += clock.now - oldNow; + tickTo += clock.now - oldNow; + } + clock.duringTick = false; + + // corner case: during runJobs new timers were scheduled which could be in the range [clock.now, tickTo] + timer = firstTimerInRange(clock, tickFrom, tickTo); + if (timer) { + try { + clock.tick(tickTo - clock.now); // do it all again - for the remainder of the requested range + } catch (e) { + firstException = firstException || e; + } + } else { + // no timers remaining in the requested range: move the clock all the way to the end + clock.now = tickTo; + + // update nanos + nanos = nanosTotal; + } + if (firstException) { + throw firstException; + } + + if (isAsync) { + resolve(clock.now); + } else { + return clock.now; + } + } + + nextPromiseTick = + isAsync && + function () { + try { + compensationCheck(); + postTimerCall(); + doTickInner(); + } catch (e) { + reject(e); + } + }; + + compensationCheck = function () { + // compensate for any setSystemTime() call during timer callback + if (oldNow !== clock.now) { + tickFrom += clock.now - oldNow; + tickTo += clock.now - oldNow; + previous += clock.now - oldNow; + } + }; + + postTimerCall = function () { + timer = firstTimerInRange(clock, previous, tickTo); + previous = tickFrom; + }; + + return doTickInner(); + } + + /** + * @param {tickValue} {string|number} number of milliseconds or a human-readable value like "01:11:15" + */ + clock.tick = function tick(tickValue) { + return doTick(tickValue, false); + }; + + if (typeof _global.Promise !== "undefined") { + clock.tickAsync = function tickAsync(ms) { + return new _global.Promise(function (resolve, reject) { + originalSetTimeout(function () { + try { + doTick(ms, true, resolve, reject); + } catch (e) { + reject(e); + } + }); + }); + }; + } + + clock.next = function next() { + runJobs(clock); + var timer = firstTimer(clock); + if (!timer) { + return clock.now; + } + + clock.duringTick = true; + try { + clock.now = timer.callAt; + callTimer(clock, timer); + runJobs(clock); + return clock.now; + } finally { + clock.duringTick = false; + } + }; + + if (typeof _global.Promise !== "undefined") { + clock.nextAsync = function nextAsync() { + return new _global.Promise(function (resolve, reject) { + originalSetTimeout(function () { + try { + var timer = firstTimer(clock); + if (!timer) { + resolve(clock.now); + return; + } + + var err; + clock.duringTick = true; + clock.now = timer.callAt; + try { + callTimer(clock, timer); + } catch (e) { + err = e; + } + clock.duringTick = false; + + originalSetTimeout(function () { + if (err) { + reject(err); + } else { + resolve(clock.now); + } + }); + } catch (e) { + reject(e); + } + }); + }); + }; + } + + clock.runAll = function runAll() { + var numTimers, i; + runJobs(clock); + for (i = 0; i < clock.loopLimit; i++) { + if (!clock.timers) { + return clock.now; + } + + numTimers = Object.keys(clock.timers).length; + if (numTimers === 0) { + return clock.now; + } + + clock.next(); + } + + throw new Error( + "Aborting after running " + + clock.loopLimit + + " timers, assuming an infinite loop!" + ); + }; + + clock.runToFrame = function runToFrame() { + return clock.tick(getTimeToNextFrame()); + }; + + if (typeof _global.Promise !== "undefined") { + clock.runAllAsync = function runAllAsync() { + return new _global.Promise(function (resolve, reject) { + var i = 0; + function doRun() { + originalSetTimeout(function () { + try { + var numTimers; + if (i < clock.loopLimit) { + if (!clock.timers) { + resolve(clock.now); + return; + } + + numTimers = Object.keys(clock.timers) + .length; + if (numTimers === 0) { + resolve(clock.now); + return; + } + + clock.next(); + + i++; + + doRun(); + return; + } + + reject( + new Error( + "Aborting after running " + + clock.loopLimit + + " timers, assuming an infinite loop!" + ) + ); + } catch (e) { + reject(e); + } + }); + } + doRun(); + }); + }; + } + + clock.runToLast = function runToLast() { + var timer = lastTimer(clock); + if (!timer) { + runJobs(clock); + return clock.now; + } + + return clock.tick(timer.callAt - clock.now); + }; + + if (typeof _global.Promise !== "undefined") { + clock.runToLastAsync = function runToLastAsync() { + return new _global.Promise(function (resolve, reject) { + originalSetTimeout(function () { + try { + var timer = lastTimer(clock); + if (!timer) { + resolve(clock.now); + } + + resolve(clock.tickAsync(timer.callAt)); + } catch (e) { + reject(e); + } + }); + }); + }; + } + + clock.reset = function reset() { + nanos = 0; + clock.timers = {}; + clock.jobs = []; + clock.now = start; + }; + + clock.setSystemTime = function setSystemTime(systemTime) { + // determine time difference + var newNow = getEpoch(systemTime); + var difference = newNow - clock.now; + var id, timer; + + adjustedSystemTime[0] = adjustedSystemTime[0] + difference; + adjustedSystemTime[1] = adjustedSystemTime[1] + nanos; + // update 'system clock' + clock.now = newNow; + nanos = 0; + + // update timers and intervals to keep them stable + for (id in clock.timers) { + if (clock.timers.hasOwnProperty(id)) { + timer = clock.timers[id]; + timer.createdAt += difference; + timer.callAt += difference; + } + } + }; + + if (performancePresent) { + clock.performance = Object.create(null); + + if (hasPerformancePrototype) { + var proto = _global.Performance.prototype; + + Object.getOwnPropertyNames(proto).forEach(function (name) { + if (name.indexOf("getEntries") === 0) { + // match expected return type for getEntries functions + clock.performance[name] = NOOP_ARRAY; + } else { + clock.performance[name] = NOOP; + } + }); + } + + clock.performance.now = function FakeTimersNow() { + var hrt = hrtime(); + var millis = hrt[0] * 1000 + hrt[1] / 1e6; + return millis; + }; + } + + if (hrtimePresent) { + clock.hrtime = hrtime; + } + + return clock; + } + + /* eslint-disable complexity */ + + /** + * @param {Config=} [config] Optional config + * @returns {Clock} + */ + function install(config) { + if ( + arguments.length > 1 || + config instanceof Date || + Array.isArray(config) || + typeof config === "number" + ) { + throw new TypeError( + "FakeTimers.install called with " + + String(config) + + " install requires an object parameter" + ); + } + + // eslint-disable-next-line no-param-reassign + config = typeof config !== "undefined" ? config : {}; + config.shouldAdvanceTime = config.shouldAdvanceTime || false; + config.advanceTimeDelta = config.advanceTimeDelta || 20; + + if (config.target) { + throw new TypeError( + "config.target is no longer supported. Use `withGlobal(target)` instead." + ); + } + + var i, l; + var clock = createClock(config.now, config.loopLimit); + + clock.uninstall = function () { + return uninstall(clock, config); + }; + + clock.methods = config.toFake || []; + + if (clock.methods.length === 0) { + // do not fake nextTick by default - GitHub#126 + clock.methods = Object.keys(timers).filter(function (key) { + return key !== "nextTick" && key !== "queueMicrotask"; + }); + } + + for (i = 0, l = clock.methods.length; i < l; i++) { + if (clock.methods[i] === "hrtime") { + if ( + _global.process && + typeof _global.process.hrtime === "function" + ) { + hijackMethod(_global.process, clock.methods[i], clock); + } + } else if (clock.methods[i] === "nextTick") { + if ( + _global.process && + typeof _global.process.nextTick === "function" + ) { + hijackMethod(_global.process, clock.methods[i], clock); + } + } else { + if ( + clock.methods[i] === "setInterval" && + config.shouldAdvanceTime === true + ) { + var intervalTick = doIntervalTick.bind( + null, + clock, + config.advanceTimeDelta + ); + var intervalId = _global[clock.methods[i]]( + intervalTick, + config.advanceTimeDelta + ); + clock.attachedInterval = intervalId; + } + hijackMethod(_global, clock.methods[i], clock); + } + } + + return clock; + } + + /* eslint-enable complexity */ + + return { + timers: timers, + createClock: createClock, + install: install, + withGlobal: withGlobal, + }; +} + +/* eslint-enable complexity */ + +var defaultImplementation = withGlobal(globalObject); + +exports.timers = defaultImplementation.timers; +exports.createClock = defaultImplementation.createClock; +exports.install = defaultImplementation.install; +exports.withGlobal = withGlobal; diff --git a/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts new file mode 100644 index 0000000000..688b234778 --- /dev/null +++ b/node_modules/@types/sinon/node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts @@ -0,0 +1,187 @@ +export type Clock = { + now: number; + timeouts: any; + Date: typeof globalThis.Date; + loopLimit: number; + requestIdleCallback: (func: Function, timeout: number) => number; + cancelIdleCallback: (timerId: number) => void; + setTimeout: typeof setTimeout; + clearTimeout: typeof clearTimeout; + nextTick: (func: Function, ...args: any[]) => void; + queueMicrotask: typeof queueMicrotask; + setInterval: typeof setInterval; + clearInterval: typeof clearInterval; + setImmediate: (func: (...args: any[]) => void, ...args: any[]) => NodeTimer; + clearImmediate: (timerId: NodeTimer) => void; + countTimers: () => number; + requestAnimationFrame: (func: (timer: number) => void) => number; + cancelAnimationFrame: (timerId: number) => void; + runMicrotasks: () => void; + tick: (tickValue: string | number) => number; + tickAsync: (tickValue: string | number) => Promise; + next: () => number; + nextAsync: () => Promise; + runAll: () => number; + runToFrame: () => number; + runAllAsync: () => Promise; + runToLast: () => number; + runToLastAsync: () => Promise; + reset: () => void; + setSystemTime: (systemTime: number | Date) => void; + performance: ({ + now(): number; + }); + hrTime: (prev: any) => number[]; + /** + * Uninstall the clock. + */ + uninstall: () => void; + methods: any; +}; +/** + * Configuration object for the `install` method. + */ +export type Config = { + /** + * a number (in milliseconds) or a Date object (default epoch) + */ + now?: number | Date; + /** + * names of the methods that should be faked. + */ + toFake?: string[]; + /** + * the maximum number of timers that will be run when calling runAll() + */ + loopLimit?: number; + /** + * tells FakeTimers to increment mocked time automatically (default false) + */ + shouldAdvanceTime?: boolean; + /** + * increment mocked time every <> ms (default: 20ms) + */ + advanceTimeDelta?: number; +}; +export type NodeTimer = { + hasRef: () => boolean; + ref: () => any; + unref: () => any; +}; +export namespace timers { + const setTimeout_1: typeof globalThis.setTimeout; + export { setTimeout_1 as setTimeout }; + const clearTimeout_1: typeof globalThis.clearTimeout; + export { clearTimeout_1 as clearTimeout }; + const setInterval_1: typeof globalThis.setInterval; + export { setInterval_1 as setInterval }; + const clearInterval_1: typeof globalThis.clearInterval; + export { clearInterval_1 as clearInterval }; + const Date_1: typeof globalThis.Date; + export { Date_1 as Date }; + export const setImmediate: (fn: (...args: any[]) => void, ...args: any[]) => NodeTimer; + export const clearImmediate: (id: NodeTimer) => void; + export const hrtime: (time?: [number, number]) => [number, number]; + export const nextTick: (fn: Function, ...args: any[]) => void; + export const performance: ({ + now(): number; + }) | undefined; + export const requestAnimationFrame: (fn: (timer: number) => void) => number; + const queueMicrotask_1: boolean | undefined; + export { queueMicrotask_1 as queueMicrotask }; + export const cancelAnimationFrame: (id: number) => void; + export const requestIdleCallback: (fn: (deadline: any) => void, options?: any) => number; + export const cancelIdleCallback: (id: number) => void; +} +/** + * @param {Date|number} [start] the system time - non-integer values are floored + * @param {number} [loopLimit] maximum number of timers that will be run when calling runAll() + * @returns {Clock} + */ +export function createClock(start?: Date | number, loopLimit?: number): Clock; +/** + * @param {Config=} [config] Optional config + * @returns {Clock} + */ +export function install(config?: Config | undefined, ...args: any[]): Clock; +/** + * @typedef {object} Clock + * @property {number} now + * @property {any} timeouts + * @property {typeof globalThis.Date} Date + * @property {number} loopLimit + * @property {(func: Function, timeout: number) => number} requestIdleCallback + * @property {(timerId: number) => void} cancelIdleCallback + * @property {setTimeout} setTimeout + * @property {clearTimeout} clearTimeout + * @property {(func: Function, ...args: any[]) => void} nextTick + * @property {queueMicrotask} queueMicrotask + * @property {setInterval} setInterval + * @property {clearInterval} clearInterval + * @property {(func: (...args: any[]) => void, ...args: any[]) => NodeTimer} setImmediate + * @property {(timerId: NodeTimer) => void} clearImmediate + * @property {() => number} countTimers + * @property {(func: (timer: number) => void) => number} requestAnimationFrame + * @property {(timerId: number) => void} cancelAnimationFrame + * @property {() => void} runMicrotasks + * @property {(tickValue: string | number) => number} tick + * @property {(tickValue: string | number) => Promise} tickAsync + * @property {() => number} next + * @property {() => Promise} nextAsync + * @property {() => number} runAll + * @property {() => number} runToFrame + * @property {() => Promise} runAllAsync + * @property {() => number} runToLast + * @property {() => Promise} runToLastAsync + * @property {() => void} reset + * @property {(systemTime: number | Date) => void} setSystemTime + * @property {({now(): number})} performance + * @property {(prev: any) => number[]} hrTime + * @property {() => void} uninstall Uninstall the clock. + * @property {any} methods + */ +/** + * Configuration object for the `install` method. + * + * @typedef {object} Config + * @property {number|Date} [now] a number (in milliseconds) or a Date object (default epoch) + * @property {string[]} [toFake] names of the methods that should be faked. + * @property {number} [loopLimit] the maximum number of timers that will be run when calling runAll() + * @property {boolean} [shouldAdvanceTime] tells FakeTimers to increment mocked time automatically (default false) + * @property {number} [advanceTimeDelta] increment mocked time every <> ms (default: 20ms) + */ +/** + * @typedef {object} NodeTimer + * @property {() => boolean} hasRef + * @property {() => any} ref + * @property {() => any} unref + */ +/** + * Mocks available features in the specified global namespace. + * + * @param {*} _global Namespace to mock (e.g. `window`) + */ +export function withGlobal(_global: any): { + timers: { + setTimeout: typeof setTimeout; + clearTimeout: typeof clearTimeout; + setInterval: typeof setInterval; + clearInterval: typeof clearInterval; + Date: typeof globalThis.Date; + setImmediate?: (fn: (...args: any[]) => void, ...args: any[]) => NodeTimer; + clearImmediate?: (id: NodeTimer) => void; + hrtime?: (time?: [number, number]) => [number, number]; + nextTick?: (fn: Function, ...args: any[]) => void; + performance?: ({ + now(): number; + }) | undefined; + requestAnimationFrame?: (fn: (timer: number) => void) => number; + queueMicrotask?: boolean | undefined; + cancelAnimationFrame?: (id: number) => void; + requestIdleCallback?: (fn: (deadline: any) => void, options?: any) => number; + cancelIdleCallback?: (id: number) => void; + }; + createClock: (start?: Date | number, loopLimit?: number) => Clock; + install: (config?: Config | undefined, ...args: any[]) => Clock; + withGlobal: typeof withGlobal; +}; diff --git a/node_modules/@types/sinon/package.json b/node_modules/@types/sinon/package.json old mode 100644 new mode 100755 index c487897526..aa69c53c69 --- a/node_modules/@types/sinon/package.json +++ b/node_modules/@types/sinon/package.json @@ -1,7 +1,8 @@ { "name": "@types/sinon", - "version": "7.5.2", + "version": "10.0.2", "description": "TypeScript definitions for Sinon", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sinon", "license": "MIT", "contributors": [ { @@ -9,11 +10,6 @@ "url": "https://github.com/mrbigdog2u", "githubUsername": "mrbigdog2u" }, - { - "name": "Jonathan Little", - "url": "https://github.com/rationull", - "githubUsername": "rationull" - }, { "name": "Lukas Spieß", "url": "https://github.com/lumaxis", @@ -53,29 +49,19 @@ "name": "Simon Schick", "url": "https://github.com/SimonSchick", "githubUsername": "SimonSchick" - }, - { - "name": "Roey Berman", - "url": "https://github.com/bergundy", - "githubUsername": "bergundy" } ], "main": "", "types": "index.d.ts", - "typesVersions": { - ">=3.1.0-0": { - "*": [ - "ts3.1/*" - ] - } - }, "repository": { "type": "git", "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", "directory": "types/sinon" }, "scripts": {}, - "dependencies": {}, - "typesPublisherContentHash": "6e0d06aaa3706e565221de95281d8cbf6a06a29c4151df20618abe3b435c3447", - "typeScriptVersion": "2.8" + "dependencies": { + "@sinonjs/fake-timers": "^7.1.0" + }, + "typesPublisherContentHash": "d9f02a4574f6f32057808563b4551e558075d0c93c5739b604521c743c4bb712", + "typeScriptVersion": "3.6" } \ No newline at end of file diff --git a/node_modules/@types/sinon/ts3.1/index.d.ts b/node_modules/@types/sinon/ts3.1/index.d.ts deleted file mode 100644 index cc9b427bbb..0000000000 --- a/node_modules/@types/sinon/ts3.1/index.d.ts +++ /dev/null @@ -1,1798 +0,0 @@ -// sinon uses DOM dependencies which are absent in browser-less environment like node.js -// to avoid compiler errors this monkey patch is used -// see more details in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11351 -interface Event {} // tslint:disable-line no-empty-interface -interface Document {} // tslint:disable-line no-empty-interface - -declare namespace Sinon { - type MatchArguments = { - [K in keyof T]: SinonMatcher - | (T[K] extends object ? MatchArguments : never) - | T[K]; - }; - - interface SinonSpyCallApi { - // Properties - /** - * Array of received arguments. - */ - args: TArgs; - - // Methods - /** - * Returns true if the spy was called at least once with @param obj as this. - * calledOn also accepts a matcher spyCall.calledOn(sinon.match(fn)) (see matchers). - * @param obj - */ - calledOn(obj: any): boolean; - /** - * Returns true if spy was called at least once with the provided arguments. - * Can be used for partial matching, Sinon only checks the provided arguments against actual arguments, - * so a call that received the provided arguments (in the same spots) and possibly others as well will return true. - * @param args - */ - calledWith(...args: Partial>): boolean; - /** - * Returns true if spy was called at least once with the provided arguments and no others. - */ - calledWithExactly(...args: MatchArguments): boolean; - /** - * Returns true if spy/stub was called the new operator. - * Beware that this is inferred based on the value of the this object and the spy function’s prototype, - * so it may give false positives if you actively return the right kind of object. - */ - calledWithNew(): boolean; - /** - * Returns true if spy was called at exactly once with the provided arguments. - * @param args - */ - calledOnceWith(...args: MatchArguments): boolean; - calledOnceWithExactly(...args: MatchArguments): boolean; - /** - * Returns true if spy was called with matching arguments (and possibly others). - * This behaves the same as spy.calledWith(sinon.match(arg1), sinon.match(arg2), ...). - * @param args - */ - calledWithMatch(...args: TArgs): boolean; - /** - * Returns true if call did not receive provided arguments. - * @param args - */ - notCalledWith(...args: MatchArguments): boolean; - /** - * Returns true if call did not receive matching arguments. - * This behaves the same as spyCall.notCalledWith(sinon.match(arg1), sinon.match(arg2), ...). - * @param args - */ - notCalledWithMatch(...args: TArgs): boolean; - /** - * Returns true if spy returned the provided value at least once. - * Uses deep comparison for objects and arrays. Use spy.returned(sinon.match.same(obj)) for strict comparison (see matchers). - * @param value - */ - returned(value: TReturnValue|SinonMatcher): boolean; - /** - * Returns true if spy threw an exception at least once. - */ - threw(): boolean; - /** - * Returns true if spy threw an exception of the provided type at least once. - */ - threw(type: string): boolean; - /** - * Returns true if spy threw the provided exception object at least once. - */ - threw(obj: any): boolean; - /** - * Like yield, but with an explicit argument number specifying which callback to call. - * Useful if a function is called with more than one callback, and simply calling the first callback is not desired. - * @param pos - */ - callArg(pos: number): void; - callArgOn(pos: number, obj: any, ...args: any[]): void; - /** - * Like callArg, but with arguments. - */ - callArgWith(pos: number, ...args: any[]): void; - callArgOnWith(pos: number, obj: any, ...args: any[]): void; - /** - * Invoke callbacks passed to the stub with the given arguments. - * If the stub was never called with a function argument, yield throws an error. - * Returns an Array with all callbacks return values in the order they were called, if no error is thrown. - * Also aliased as invokeCallback. - */ - yield(...args: any[]): void; - yieldOn(obj: any, ...args: any[]): void; - /** - * Invokes callbacks passed as a property of an object to the stub. - * Like yield, yieldTo grabs the first matching argument, finds the callback and calls it with the (optional) arguments. - */ - yieldTo(property: string, ...args: any[]): void; - yieldToOn(property: string, obj: any, ...args: any[]): void; - } - - interface SinonSpyCall - extends SinonSpyCallApi { - /** - * The call’s this value. - */ - thisValue: any; - /** - * Exception thrown, if any. - */ - exception: any; - /** - * Return value. - */ - returnValue: TReturnValue; - /** - * This property is a convenience for a call’s callback. - * When the last argument in a call is a Function, then callback will reference that. Otherwise it will be undefined. - */ - callback: Function | undefined; - /** - * This property is a convenience for the last argument of the call. - */ - lastArg: any; - - /** - * Returns true if the spy call occurred before another spy call. - * @param call - * - */ - calledBefore(call: SinonSpyCall): boolean; - /** - * Returns true if the spy call occurred after another spy call. - * @param call - */ - calledAfter(call: SinonSpyCall): boolean; - } - - interface SinonSpy - extends Pick< - SinonSpyCallApi, - Exclude, 'args'> - > { - // Properties - /** - * The number of recorded calls. - */ - callCount: number; - /** - * true if the spy was called at least once - */ - called: boolean; - /** - * true if the spy was not called - */ - notCalled: boolean; - /** - * true if spy was called exactly once - */ - calledOnce: boolean; - /** - * true if the spy was called exactly twice - */ - calledTwice: boolean; - /** - * true if the spy was called exactly thrice - */ - calledThrice: boolean; - /** - * The first call - */ - firstCall: SinonSpyCall; - /** - * The second call - */ - secondCall: SinonSpyCall; - /** - * The third call - */ - thirdCall: SinonSpyCall; - /** - * The last call - */ - lastCall: SinonSpyCall; - /** - * Array of this objects, spy.thisValues[0] is the this object for the first call. - */ - thisValues: any[]; - /** - * Array of arguments received, spy.args[0] is an array of arguments received in the first call. - */ - args: TArgs[]; - /** - * Array of exception objects thrown, spy.exceptions[0] is the exception thrown by the first call. - * If the call did not throw an error, the value at the call’s location in .exceptions will be undefined. - */ - exceptions: any[]; - /** - * Array of return values, spy.returnValues[0] is the return value of the first call. - * If the call did not explicitly return a value, the value at the call’s location in .returnValues will be undefined. - */ - returnValues: TReturnValue[]; - - // Methods - (...args: TArgs): TReturnValue; - - /** - * Returns true if the spy was called before @param anotherSpy - * @param anotherSpy - */ - calledBefore(anotherSpy: SinonSpy): boolean; - /** - * Returns true if the spy was called after @param anotherSpy - * @param anotherSpy - */ - calledAfter(anotherSpy: SinonSpy): boolean; - /** - * Returns true if spy was called before @param anotherSpy, and no spy calls occurred between spy and @param anotherSpy. - * @param anotherSpy - */ - calledImmediatelyBefore(anotherSpy: SinonSpy): boolean; - /** - * Returns true if spy was called after @param anotherSpy, and no spy calls occurred between @param anotherSpy and spy. - * @param anotherSpy - */ - calledImmediatelyAfter(anotherSpy: SinonSpy): boolean; - - /** - * Creates a spy that only records calls when the received arguments match those passed to withArgs. - * This is useful to be more expressive in your assertions, where you can access the spy with the same call. - * @param args Expected args - */ - withArgs(...args: MatchArguments): SinonSpy; - /** - * Returns true if the spy was always called with @param obj as this. - * @param obj - */ - alwaysCalledOn(obj: any): boolean; - /** - * Returns true if spy was always called with the provided arguments (and possibly others). - */ - alwaysCalledWith(...args: MatchArguments): boolean; - /** - * Returns true if spy was always called with the exact provided arguments. - * @param args - */ - alwaysCalledWithExactly(...args: MatchArguments): boolean; - /** - * Returns true if spy was always called with matching arguments (and possibly others). - * This behaves the same as spy.alwaysCalledWith(sinon.match(arg1), sinon.match(arg2), ...). - * @param args - */ - alwaysCalledWithMatch(...args: TArgs): boolean; - /** - * Returns true if the spy/stub was never called with the provided arguments. - * @param args - */ - neverCalledWith(...args: MatchArguments): boolean; - /** - * Returns true if the spy/stub was never called with matching arguments. - * This behaves the same as spy.neverCalledWith(sinon.match(arg1), sinon.match(arg2), ...). - * @param args - */ - neverCalledWithMatch(...args: TArgs): boolean; - /** - * Returns true if spy always threw an exception. - */ - alwaysThrew(): boolean; - /** - * Returns true if spy always threw an exception of the provided type. - */ - alwaysThrew(type: string): boolean; - /** - * Returns true if spy always threw the provided exception object. - */ - alwaysThrew(obj: any): boolean; - /** - * Returns true if spy always returned the provided value. - * @param obj - */ - alwaysReturned(obj: any): boolean; - /** - * Invoke callbacks passed to the stub with the given arguments. - * If the stub was never called with a function argument, yield throws an error. - * Returns an Array with all callbacks return values in the order they were called, if no error is thrown. - */ - invokeCallback(...args: TArgs): void; - /** - * Set the displayName of the spy or stub. - * @param name - */ - named(name: string): SinonSpy; - /** - * Returns the nth call. - * Accessing individual calls helps with more detailed behavior verification when the spy is called more than once. - * @param n - */ - getCall(n: number): SinonSpyCall; - /** - * Returns an Array of all calls recorded by the spy. - */ - getCalls(): Array>; - /** - * Resets the state of a spy. - */ - resetHistory(): void; - /** - * Returns the passed format string with the following replacements performed: - * * %n - the name of the spy "spy" by default) - * * %c - the number of times the spy was called, in words ("once", "twice", etc.) - * * %C - a list of string representations of the calls to the spy, with each call prefixed by a newline and four spaces - * * %t - a comma-delimited list of this values the spy was called on - * * %n - the formatted value of the nth argument passed to printf - * * %* - a comma-delimited list of the (non-format string) arguments passed to printf - * * %D - a multi-line list of the arguments received by all calls to the spy - * @param format - * @param args - */ - printf(format: string, ...args: any[]): string; - /** - * Replaces the spy with the original method. Only available if the spy replaced an existing method. - */ - restore(): void; - } - - interface SinonSpyStatic { - /** - * Creates an anonymous function that records arguments, this value, exceptions and return values for all calls. - */ - (): SinonSpy; - /** - * Spies on the provided function - */ - any>(func: F): SinonSpy, ReturnType>; - /** - * Creates a spy for object.method and replaces the original method with the spy. - * An exception is thrown if the property is not already a function. - * The spy acts exactly like the original method in all cases. - * The original method can be restored by calling object.method.restore(). - * The returned spy is the function object which replaced the original method. spy === object.method. - */ - (obj: T, method: K): T[K] extends ( - ...args: infer TArgs - ) => infer TReturnValue - ? SinonSpy - : SinonSpy; - - (obj: T, method: K, types: Array<('get'|'set')>): PropertyDescriptor & { - get: SinonSpy<[], T[K]>; - set: SinonSpy<[T[K]], void>; - }; - } - - interface SinonStub - extends SinonSpy { - /** - * Resets the stub’s behaviour to the default behaviour - * You can reset behaviour of all stubs using sinon.resetBehavior() - */ - resetBehavior(): void; - /** - * Resets both behaviour and history of the stub. - * This is equivalent to calling both stub.resetBehavior() and stub.resetHistory() - * Updated in sinon@2.0.0 - * Since sinon@5.0.0 - * As a convenience, you can apply stub.reset() to all stubs using sinon.reset() - */ - reset(): void; - /** - * Causes the stub to return promises using a specific Promise library instead of the global one when using stub.rejects or stub.resolves. - * Returns the stub to allow chaining. - */ - usingPromise(promiseLibrary: any): SinonStub; - - /** - * Makes the stub return the provided @param obj value. - * @param obj - */ - returns(obj: TReturnValue): SinonStub; - /** - * Causes the stub to return the argument at the provided @param index. - * stub.returnsArg(0); causes the stub to return the first argument. - * If the argument at the provided index is not available, prior to sinon@6.1.2, an undefined value will be returned; - * starting from sinon@6.1.2, a TypeError will be thrown. - * @param index - */ - returnsArg(index: number): SinonStub; - /** - * Causes the stub to return its this value. - * Useful for stubbing jQuery-style fluent APIs. - */ - returnsThis(): SinonStub; - /** - * Causes the stub to return a Promise which resolves to the provided value. - * When constructing the Promise, sinon uses the Promise.resolve method. - * You are responsible for providing a polyfill in environments which do not provide Promise. - * The Promise library can be overwritten using the usingPromise method. - * Since sinon@2.0.0 - */ - resolves(value?: TReturnValue extends PromiseLike ? TResolveValue : any): SinonStub; - /** - * Causes the stub to return a Promise which resolves to the argument at the provided index. - * stub.resolvesArg(0); causes the stub to return a Promise which resolves to the first argument. - * If the argument at the provided index is not available, a TypeError will be thrown. - */ - resolvesArg(index: number): SinonStub; - /** - * Causes the stub to return a Promise which resolves to its this value. - */ - resolvesThis(): SinonStub; - /** - * Causes the stub to throw an exception (Error). - * @param type - */ - throws(type?: string): SinonStub; - /** - * Causes the stub to throw the provided exception object. - */ - throws(obj: any): SinonStub; - /** - * Causes the stub to throw the argument at the provided index. - * stub.throwsArg(0); causes the stub to throw the first argument as the exception. - * If the argument at the provided index is not available, a TypeError will be thrown. - * Since sinon@2.3.0 - * @param index - */ - throwsArg(index: number): SinonStub; - throwsException(type?: string): SinonStub; - throwsException(obj: any): SinonStub; - /** - * Causes the stub to return a Promise which rejects with an exception (Error). - * When constructing the Promise, sinon uses the Promise.reject method. - * You are responsible for providing a polyfill in environments which do not provide Promise. - * The Promise library can be overwritten using the usingPromise method. - * Since sinon@2.0.0 - */ - rejects(): SinonStub; - /** - * Causes the stub to return a Promise which rejects with an exception of the provided type. - * Since sinon@2.0.0 - */ - rejects(errorType: string): SinonStub; - /** - * Causes the stub to return a Promise which rejects with the provided exception object. - * Since sinon@2.0.0 - */ - rejects(value: any): SinonStub; - /** - * Causes the stub to call the argument at the provided index as a callback function. - * stub.callsArg(0); causes the stub to call the first argument as a callback. - * If the argument at the provided index is not available or is not a function, a TypeError will be thrown. - */ - callsArg(index: number): SinonStub; - /** - * Causes the original method wrapped into the stub to be called when none of the conditional stubs are matched. - */ - callThrough(): SinonStub; - /** - * Like stub.callsArg(index); but with an additional parameter to pass the this context. - * @param index - * @param context - */ - callsArgOn(index: number, context: any): SinonStub; - /** - * Like callsArg, but with arguments to pass to the callback. - * @param index - * @param args - */ - callsArgWith(index: number, ...args: any[]): SinonStub; - /** - * Like above but with an additional parameter to pass the this context. - * @param index - * @param context - * @param args - */ - callsArgOnWith( - index: number, - context: any, - ...args: any[] - ): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param index - */ - callsArgAsync(index: number): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param index - * @param context - */ - callsArgOnAsync(index: number, context: any): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - */ - callsArgWithAsync(index: number, ...args: any[]): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - */ - callsArgOnWithAsync( - index: number, - context: any, - ...args: any[] - ): SinonStub; - /** - * Makes the stub call the provided @param func when invoked. - * @param func - */ - callsFake(func: (...args: TArgs) => TReturnValue): SinonStub; - /** - * Replaces a new getter for this stub. - */ - get(func: () => any): SinonStub; - /** - * Defines a new setter for this stub. - * @param func - */ - set(func: (v: any) => void): SinonStub; - /** - * Defines the behavior of the stub on the @param n call. Useful for testing sequential interactions. - * There are methods onFirstCall, onSecondCall,onThirdCall to make stub definitions read more naturally. - * onCall can be combined with all of the behavior defining methods in this section. In particular, it can be used together with withArgs. - * @param n - */ - onCall(n: number): SinonStub; - /** - * Alias for stub.onCall(0); - */ - onFirstCall(): SinonStub; - /** - * Alias for stub.onCall(1); - */ - onSecondCall(): SinonStub; - /** - * Alias for stub.onCall(2); - */ - onThirdCall(): SinonStub; - /** - * Defines a new value for this stub. - * @param val - */ - value(val: any): SinonStub; - /** - * Set the displayName of the spy or stub. - * @param name - */ - named(name: string): SinonStub; - /** - * Similar to callsArg. - * Causes the stub to call the first callback it receives with the provided arguments (if any). - * If a method accepts more than one callback, you need to use callsArg to have the stub invoke other callbacks than the first one. - */ - yields(...args: any[]): SinonStub; - /** - * Like above but with an additional parameter to pass the this context. - */ - yieldsOn(context: any, ...args: any[]): SinonStub; - yieldsRight(...args: any[]): SinonStub; - /** - * Causes the spy to invoke a callback passed as a property of an object to the spy. - * Like yields, yieldsTo grabs the first matching argument, finds the callback and calls it with the (optional) arguments. - * @param property - * @param args - */ - yieldsTo(property: string, ...args: any[]): SinonStub; - /** - * Like above but with an additional parameter to pass the this context. - */ - yieldsToOn( - property: string, - context: any, - ...args: any[] - ): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param args - */ - yieldsAsync(...args: any[]): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param context - * @param args - */ - yieldsOnAsync(context: any, ...args: any[]): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param property - * @param args - */ - yieldsToAsync(property: string, ...args: any[]): SinonStub; - /** - * Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with process.nextTick. - * In a browser the callback is deferred with setTimeout(callback, 0). - * @param property - * @param context - * @param args - */ - yieldsToOnAsync( - property: string, - context: any, - ...args: any[] - ): SinonStub; - /** - * Stubs the method only for the provided arguments. - * This is useful to be more expressive in your assertions, where you can access the spy with the same call. - * It is also useful to create a stub that can act differently in response to different arguments. - * @param args - */ - withArgs(...args: MatchArguments): SinonStub; - } - - interface SinonStubStatic { - /* tslint:disable:no-unnecessary-generics */ - - /** - * Creates an anonymous stub function - */ - (): SinonStub; - - /* tslint:enable:no-unnecessary-generics */ - - /** - * Stubs all the object’s methods. - * Note that it’s usually better practice to stub individual methods, particularly on objects that you don’t understand or control all the methods for (e.g. library dependencies). - * Stubbing individual methods tests intent more precisely and is less susceptible to unexpected behavior as the object’s code evolves. - * If you want to create a stub object of MyConstructor, but don’t want the constructor to be invoked, use this utility function. - */ - (obj: T): SinonStubbedInstance; - /** - * Replaces obj.method with a stub function. - * An exception is thrown if the property is not already a function. - * The original function can be restored by calling object.method.restore(); (or stub.restore();). - */ - (obj: T, method: K): T[K] extends ( - ...args: infer TArgs - ) => infer TReturnValue - ? SinonStub - : SinonStub; - } - - interface SinonExpectation extends SinonStub { - /** - * Specify the minimum amount of calls expected. - */ - atLeast(n: number): SinonExpectation; - /** - * Specify the maximum amount of calls expected. - * @param n - */ - atMost(n: number): SinonExpectation; - /** - * Expect the method to never be called. - */ - never(): SinonExpectation; - /** - * Expect the method to be called exactly once. - */ - once(): SinonExpectation; - /** - * Expect the method to be called exactly twice. - */ - twice(): SinonExpectation; - /** - * Expect the method to be called exactly thrice. - */ - thrice(): SinonExpectation; - /** - * Expect the method to be called exactly @param n times. - */ - exactly(n: number): SinonExpectation; - /** - * Expect the method to be called with the provided arguments and possibly others. - * An expectation instance only holds onto a single set of arguments specified with withArgs. - * Subsequent calls will overwrite the previously-specified set of arguments (even if they are different), - * so it is generally not intended that this method be invoked more than once per test case. - * @param args - */ - withArgs(...args: any[]): SinonExpectation; - /** - * Expect the method to be called with the provided arguments and no others. - * An expectation instance only holds onto a single set of arguments specified with withExactArgs. - * Subsequent calls will overwrite the previously-specified set of arguments (even if they are different), - * so it is generally not intended that this method be invoked more than once per test case. - * @param args - */ - withExactArgs(...args: any[]): SinonExpectation; - on(obj: any): SinonExpectation; - /** - * Verifies all expectations on the mock. - * If any expectation is not satisfied, an exception is thrown. - * Also restores the mocked methods. - */ - verify(): SinonExpectation; - /** - * Restores all mocked methods. - */ - restore(): void; - } - - interface SinonExpectationStatic { - /** - * Creates an expectation without a mock object, basically an anonymous mock function. - * Method name is optional and is used in exception messages to make them more readable. - * @param methodName - */ - create(methodName?: string): SinonExpectation; - } - - interface SinonMock { - /** - * Overrides obj.method with a mock function and returns it. - */ - expects(method: string): SinonExpectation; - /** - * Restores all mocked methods. - */ - restore(): void; - /** - * Verifies all expectations on the mock. - * If any expectation is not satisfied, an exception is thrown. - * Also restores the mocked methods. - */ - verify(): void; - } - - interface SinonMockStatic { - (): SinonExpectation; - /** - * Creates a mock for the provided object. - * Does not change the object, but returns a mock object to set expectations on the object’s methods. - */ - (obj: any): SinonMock; - } - - type SinonTimerId = number | { id: number }; - - interface SinonFakeTimers { - now: number; - loopLimit: number; - - setTimeout( - callback: (...args: TArgs) => void, - timeout: number, - ...args: TArgs - ): SinonTimerId; - clearTimeout(id: SinonTimerId): void; - - setInterval( - callback: (...args: TArgs) => void, - timeout: number, - ...args: TArgs - ): SinonTimerId; - clearInterval(id: SinonTimerId): void; - - setImmediate( - callback: (...args: TArgs) => void, - ...args: TArgs - ): SinonTimerId; - clearImmediate(id: SinonTimerId): void; - - requestAnimationFrame(callback: (time: number) => void): SinonTimerId; - cancelAnimationFrame(id: SinonTimerId): void; - - nextTick( - callback: (...args: TArgs) => void, - ...args: TArgs): void; - queueMicrotask(callback: () => void): void; - - requestIdleCallback(func: (...args: TArgs) => void, timeout?: number, ...args: - TArgs): SinonTimerId; - cancelIdleCallback(timerId: SinonTimerId): void; - - /** - * Tick the clock ahead time milliseconds. - * Causes all timers scheduled within the affected time range to be called. - * time may be the number of milliseconds to advance the clock by or a human-readable string. - * Valid string formats are “08” for eight seconds, “01:00” for one minute and “02:34:10” for two hours, 34 minutes and ten seconds. - * time may be negative, which causes the clock to change but won’t fire any callbacks. - * @param ms - */ - tick(ms: number | string): number; - /** - * Advances the clock to the the moment of the first scheduled timer, firing it. - */ - next(): number; - /** - * This runs all pending timers until there are none remaining. If new timers are added while it is executing they will be run as well. - * This makes it easier to run asynchronous tests to completion without worrying about the number of timers they use, or the delays in those timers. - */ - runAll(): number; - runToLast(): number; - reset(): void; - runMicrotasks(): void; - runToFrame(): number; - - Date(): Date; - Date(year: number): Date; - Date(year: number, month: number): Date; - Date(year: number, month: number, day: number): Date; - Date(year: number, month: number, day: number, hour: number): Date; - Date( - year: number, - month: number, - day: number, - hour: number, - minute: number - ): Date; - Date( - year: number, - month: number, - day: number, - hour: number, - minute: number, - second: number - ): Date; - Date( - year: number, - month: number, - day: number, - hour: number, - minute: number, - second: number, - ms: number - ): Date; - - /** - * Restore the faked methods. - * Call in e.g. tearDown. - */ - restore(): void; - uninstall(): void; - - /** - * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp - * without affecting timers, intervals or immediates. - * @param now The new 'now' in unix milliseconds - */ - setSystemTime(now: number): void; - /** - * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp - * without affecting timers, intervals or immediates. - * @param now The new 'now' as a JavaScript Date - */ - setSystemTime(date: Date): void; - - countTimers(): number; - } - - interface SinonFakeTimersConfig { - now: number | Date; - toFake: string[]; - shouldAdvanceTime: boolean; - } - - interface SinonFakeUploadProgress { - eventListeners: { - progress: any[]; - load: any[]; - abort: any[]; - error: any[]; - }; - - addEventListener(event: string, listener: (e: Event) => any): void; - removeEventListener(event: string, listener: (e: Event) => any): void; - dispatchEvent(event: Event): void; - } - - interface SinonFakeXMLHttpRequest { - // Properties - /** - * The URL set on the request object. - */ - url: string; - /** - * The request method as a string. - */ - method: string; - /** - * An object of all request headers, i.e.: - */ - requestHeaders: any; - /** - * The request body - */ - requestBody: string; - /** - * The request’s status code. - * undefined if the request has not been handled (see respond below) - */ - status: number; - /** - * Only populated if the respond method is called (see below). - */ - statusText: string; - /** - * Whether or not the request is asynchronous. - */ - async: boolean; - /** - * Username, if any. - */ - username: string; - /** - * Password, if any. - */ - password: string; - withCredentials: boolean; - upload: SinonFakeUploadProgress; - /** - * When using respond, this property is populated with a parsed document if response headers indicate as much (see the spec) - */ - responseXML: Document; - /** - * The value of the given response header, if the request has been responded to (see respond). - * @param header - */ - getResponseHeader(header: string): string; - /** - * All response headers as an object. - */ - getAllResponseHeaders(): any; - - // Methods - /** - * Sets response headers (e.g. { "Content-Type": "text/html", ... }, updates the readyState property and fires onreadystatechange. - * @param headers - */ - setResponseHeaders(headers: any): void; - /** - * Sets the respond body, updates the readyState property and fires onreadystatechange. - * Additionally, populates responseXML with a parsed document if response headers indicate as much. - */ - setResponseBody(body: string): void; - /** - * Calls the above three methods. - */ - respond(status: number, headers: any, body: string): void; - autoRespond(ms: number): void; - /** - * Simulates a network error on the request. The onerror handler will be called and the status will be 0. - */ - error(): void; - onerror(): void; - } - - interface SinonFakeXMLHttpRequestStatic { - new (): SinonFakeXMLHttpRequest; - /** - * Default false. - * When set to true, Sinon will check added filters if certain requests should be “unfaked” - */ - useFilters: boolean; - /** - * Add a filter that will decide whether or not to fake a request. - * The filter will be called when xhr.open is called, with the exact same arguments (method, url, async, username, password). - * If the filter returns true, the request will not be faked. - * @param filter - */ - addFilter( - filter: ( - method: string, - url: string, - async: boolean, - username: string, - password: string - ) => boolean - ): void; - /** - * By assigning a function to the onCreate property of the returned object from useFakeXMLHttpRequest() - * you can subscribe to newly created FakeXMLHttpRequest objects. See below for the fake xhr object API. - * Using this observer means you can still reach objects created by e.g. jQuery.ajax (or other abstractions/frameworks). - * @param xhr - */ - onCreate(xhr: SinonFakeXMLHttpRequest): void; - /** - * Restore original function(s). - */ - restore(): void; - } - - interface SinonFakeServer extends SinonFakeServerOptions { - // Properties - /** - * Used internally to determine the HTTP method used with the provided request. - * By default this method simply returns request.method. - * When server.fakeHTTPMethods is true, the method will return the value of the _method parameter if the method is “POST”. - * This method can be overridden to provide custom behavior. - * @param request - */ - getHTTPMethod(request: SinonFakeXMLHttpRequest): string; - /** - * You can inspect the server.requests to verify request ordering, find unmatched requests or check that no requests has been done. - * server.requests is an array of all the FakeXMLHttpRequest objects that have been created. - */ - requests: SinonFakeXMLHttpRequest[]; - - // Methods - /** - * Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. - * A String representing the response body - * An Array with status, headers and response body, e.g. [200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"] - * A Function. - * Default status is 200 and default headers are none. - * When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request. - * @param body A String representing the response body - */ - respondWith(body: string): void; - /** - * Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. - * Default status is 200 and default headers are none. - * When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request. - * @param response An Array with status, headers and response body, e.g. [200, { "Content-Type": "text/html", "Content-Length": 2 }, "OK"] - */ - respondWith(response: any[]): void; - /** - * Causes the server to respond to any request not matched by another response with the provided data. The default catch-all response is [404, {}, ""]. - * Default status is 200 and default headers are none. - * When the response is a Function, it will be passed the request object. You must manually call respond on it to complete the request. - * @param fn A Function. - */ - respondWith(fn: (xhr: SinonFakeXMLHttpRequest) => void): void; - /** - * Responds to all requests to given URL, e.g. /posts/1. - */ - respondWith(url: string, body: string): void; - /** - * Responds to all requests to given URL, e.g. /posts/1. - */ - respondWith(url: string, response: any[]): void; - /** - * Responds to all requests to given URL, e.g. /posts/1. - */ - respondWith( - url: string, - fn: (xhr: SinonFakeXMLHttpRequest) => void - ): void; - /** - * Responds to all method requests to the given URL with the given response. - * method is an HTTP verb. - */ - respondWith(method: string, url: string, body: string): void; - /** - * Responds to all method requests to the given URL with the given response. - * method is an HTTP verb. - */ - respondWith(method: string, url: string, response: any[]): void; - /** - * Responds to all method requests to the given URL with the given response. - * method is an HTTP verb. - */ - respondWith( - method: string, - url: string, - fn: (xhr: SinonFakeXMLHttpRequest) => void - ): void; - /** - * URL may be a regular expression, e.g. /\\/post\\//\\d+ - * If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object: - */ - respondWith(url: RegExp, body: string): void; - /** - * URL may be a regular expression, e.g. /\\/post\\//\\d+ - * If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object: - */ - respondWith(url: RegExp, response: any[]): void; - /** - * URL may be a regular expression, e.g. /\\/post\\//\\d+ - * If the response is a Function, it will be passed any capture groups from the regular expression along with the XMLHttpRequest object: - */ - respondWith( - url: RegExp, - fn: (xhr: SinonFakeXMLHttpRequest) => void - ): void; - /** - * Responds to all method requests to URLs matching the regular expression. - */ - respondWith(method: string, url: RegExp, body: string): void; - /** - * Responds to all method requests to URLs matching the regular expression. - */ - respondWith(method: string, url: RegExp, response: any[]): void; - /** - * Responds to all method requests to URLs matching the regular expression. - */ - respondWith( - method: string, - url: RegExp, - fn: (xhr: SinonFakeXMLHttpRequest) => void - ): void; - /** - * Causes all queued asynchronous requests to receive a response. - * If none of the responses added through respondWith match, the default response is [404, {}, ""]. - * Synchronous requests are responded to immediately, so make sure to call respondWith upfront. - * If called with arguments, respondWith will be called with those arguments before responding to requests. - */ - respond(): void; - restore(): void; - } - - interface SinonFakeServerOptions { - /** - * When set to true, causes the server to automatically respond to incoming requests after a timeout. - * The default timeout is 10ms but you can control it through the autoRespondAfter property. - * Note that this feature is intended to help during mockup development, and is not suitable for use in tests. - */ - autoRespond: boolean; - /** - * When autoRespond is true, respond to requests after this number of milliseconds. Default is 10. - */ - autoRespondAfter: number; - /** - * If set to true, server will find _method parameter in POST body and recognize that as the actual method. - * Supports a pattern common to Ruby on Rails applications. For custom HTTP method faking, override server.getHTTPMethod(request). - */ - fakeHTTPMethods: boolean; - /** - * If set, the server will respond to every request immediately and synchronously. - * This is ideal for faking the server from within a test without having to call server.respond() after each request made in that test. - * As this is synchronous and immediate, this is not suitable for simulating actual network latency in tests or mockups. - * To simulate network latency with automatic responses, see server.autoRespond and server.autoRespondAfter. - */ - respondImmediately: boolean; - } - - interface SinonFakeServerStatic { - create(options?: Partial): SinonFakeServer; - } - - interface SinonExposeOptions { - prefix: string; - includeFail: boolean; - } - - interface SinonAssert { - // Properties - /** - * Defaults to AssertError. - */ - failException: string; - /** - * Every assertion fails by calling this method. - * By default it throws an error of type sinon.assert.failException. - * If the test framework looks for assertion errors by checking for a specific exception, you can simply override the kind of exception thrown. - * If that does not fit with your testing framework of choice, override the fail method to do the right thing. - */ - fail(message?: string): void; // Overridable - /** - * Called every time assertion passes. - * Default implementation does nothing. - */ - pass(assertion: any): void; // Overridable - - // Methods - - /** - * Passes if spy was never called - * @param spy - */ - notCalled(spy: SinonSpy): void; - /** - * Passes if spy was called at least once. - */ - called(spy: SinonSpy): void; - /** - * Passes if spy was called once and only once. - */ - calledOnce(spy: SinonSpy): void; - /** - * Passes if spy was called exactly twice. - */ - calledTwice(spy: SinonSpy): void; - /** - * Passes if spy was called exactly three times. - */ - calledThrice(spy: SinonSpy): void; - /** - * Passes if spy was called exactly num times. - */ - callCount(spy: SinonSpy, count: number): void; - /** - * Passes if provided spies were called in the specified order. - * @param spies - */ - callOrder(...spies: Array>): void; - /** - * Passes if spy was ever called with obj as its this value. - * It’s possible to assert on a dedicated spy call: sinon.assert.calledOn(spy.firstCall, arg1, arg2, ...);. - */ - calledOn(spyOrSpyCall: SinonSpy | SinonSpyCall, obj: any): void; - /** - * Passes if spy was always called with obj as its this value. - */ - alwaysCalledOn(spy: SinonSpy, obj: any): void; - - /** - * Passes if spy was called with the provided arguments. - * It’s possible to assert on a dedicated spy call: sinon.assert.calledWith(spy.firstCall, arg1, arg2, ...);. - * @param spyOrSpyCall - * @param args - */ - calledWith(spyOrSpyCall: SinonSpy | SinonSpyCall, ...args: MatchArguments): void; - /** - * Passes if spy was always called with the provided arguments. - * @param spy - * @param args - */ - alwaysCalledWith(spy: SinonSpy, ...args: MatchArguments): void; - /** - * Passes if spy was never called with the provided arguments. - * @param spy - * @param args - */ - neverCalledWith(spy: SinonSpy, ...args: MatchArguments): void; - /** - * Passes if spy was called with the provided arguments and no others. - * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithExactly(spy.getCall(1), arg1, arg2, ...);. - * @param spyOrSpyCall - * @param args - */ - calledWithExactly( - spyOrSpyCall: SinonSpy | SinonSpyCall, - ...args: MatchArguments - ): void; - /** - * Passes if spy was called at exactly once with the provided arguments and no others. - * @param spyOrSpyCall - * @param args - */ - calledOnceWithExactly( - spyOrSpyCall: SinonSpy | SinonSpyCall, - ...args: MatchArguments - ): void; - /** - * Passes if spy was always called with the provided arguments and no others. - */ - alwaysCalledWithExactly(spy: SinonSpy, ...args: MatchArguments): void; - /** - * Passes if spy was called with matching arguments. - * This behaves the same way as sinon.assert.calledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). - * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithMatch(spy.secondCall, arg1, arg2, ...);. - */ - calledWithMatch( - spyOrSpyCall: SinonSpy | SinonSpyCall, - ...args: TArgs - ): void; - /** - * Passes if spy was always called with matching arguments. - * This behaves the same way as sinon.assert.alwaysCalledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). - */ - alwaysCalledWithMatch(spy: SinonSpy, ...args: TArgs): void; - /** - * Passes if spy was never called with matching arguments. - * This behaves the same way as sinon.assert.neverCalledWith(spy, sinon.match(arg1), sinon.match(arg2), ...). - * @param spy - * @param args - */ - neverCalledWithMatch(spy: SinonSpy, ...args: TArgs): void; - /** - * Passes if spy was called with the new operator. - * It’s possible to assert on a dedicated spy call: sinon.assert.calledWithNew(spy.secondCall, arg1, arg2, ...);. - * @param spyOrSpyCall - */ - calledWithNew(spyOrSpyCall: SinonSpy | SinonSpyCall): void; - /** - * Passes if spy threw any exception. - */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall): void; - /** - * Passes if spy threw the given exception. - * The exception is an actual object. - * It’s possible to assert on a dedicated spy call: sinon.assert.threw(spy.thirdCall, exception);. - */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: string): void; - /** - * Passes if spy threw the given exception. - * The exception is a String denoting its type. - * It’s possible to assert on a dedicated spy call: sinon.assert.threw(spy.thirdCall, exception);. - */ - threw(spyOrSpyCall: SinonSpy | SinonSpyCall, exception: any): void; - - /** - * Like threw, only required for all calls to the spy. - */ - alwaysThrew(spy: SinonSpy): void; - /** - * Like threw, only required for all calls to the spy. - */ - alwaysThrew(spy: SinonSpy, exception: string): void; - /** - * Like threw, only required for all calls to the spy. - */ - alwaysThrew(spy: SinonSpy, exception: any): void; - - /** - * Uses sinon.match to test if the arguments can be considered a match. - */ - match(actual: any, expected: any): void; - /** - * Exposes assertions into another object, to better integrate with the test framework. - * For instance, JsTestDriver uses global assertions, and to make Sinon.JS assertions appear alongside them, you can do. - * @example sinon.assert.expose(this); - * This will give you assertCalled(spy),assertCallOrder(spy1, spy2, ...) and so on. - * The method accepts an optional options object with two options. - */ - expose(obj: any, options?: Partial): void; - } - - interface SinonMatcher { - /** - * All matchers implement and and or. This allows to logically combine mutliple matchers. - * The result is a new matchers that requires both (and) or one of the matchers (or) to return true. - * @example var stringOrNumber = sinon.match.string.or(sinon.match.number); - * var bookWithPages = sinon.match.instanceOf(Book).and(sinon.match.has("pages")); - */ - and(expr: SinonMatcher): SinonMatcher; - /** - * All matchers implement and and or. This allows to logically combine mutliple matchers. - * The result is a new matchers that requires both (and) or one of the matchers (or) to return true. - * @example var stringOrNumber = sinon.match.string.or(sinon.match.number); - * var bookWithPages = sinon.match.instanceOf(Book).and(sinon.match.has("pages")); - */ - or(expr: SinonMatcher): SinonMatcher; - test(val: any): boolean; - } - - interface SinonArrayMatcher extends SinonMatcher { - /** - * Requires an Array to be deep equal another one. - */ - deepEquals(expected: any[]): SinonMatcher; - /** - * Requires an Array to start with the same values as another one. - */ - startsWith(expected: any[]): SinonMatcher; - /** - * Requires an Array to end with the same values as another one. - */ - endsWith(expected: any[]): SinonMatcher; - /** - * Requires an Array to contain each one of the values the given array has. - */ - contains(expected: any[]): SinonMatcher; - } - - interface SimplifiedSet { - has(el: any): boolean; - } - - interface SimplifiedMap extends SimplifiedSet { - get(key: any): any; - } - - interface SinonMapMatcher extends SinonMatcher { - /** - * Requires a Map to be deep equal another one. - */ - deepEquals(expected: SimplifiedMap): SinonMatcher; - /** - * Requires a Map to contain each one of the items the given map has. - */ - contains(expected: SimplifiedMap): SinonMatcher; - } - - interface SinonSetMatcher extends SinonMatcher { - /** - * Requires a Set to be deep equal another one. - */ - deepEquals(expected: SimplifiedSet): SinonMatcher; - /** - * Requires a Set to contain each one of the items the given set has. - */ - contains(expected: SimplifiedSet): SinonMatcher; - } - - interface SinonMatch { - /** - * Requires the value to be == to the given number. - */ - (value: number): SinonMatcher; - /** - * Requires the value to be a string and have the expectation as a substring. - */ - (value: string): SinonMatcher; - /** - * Requires the value to be a string and match the given regular expression. - */ - (expr: RegExp): SinonMatcher; - /** - * See custom matchers. - */ - (callback: (value: any) => boolean, message?: string): SinonMatcher; - /** - * Requires the value to be not null or undefined and have at least the same properties as expectation. - * This supports nested matchers. - */ - (obj: object): SinonMatcher; - /** - * Matches anything. - */ - any: SinonMatcher; - /** - * Requires the value to be defined. - */ - defined: SinonMatcher; - /** - * Requires the value to be truthy. - */ - truthy: SinonMatcher; - /** - * Requires the value to be falsy. - */ - falsy: SinonMatcher; - /** - * Requires the value to be a Boolean - */ - bool: SinonMatcher; - /** - * Requires the value to be a Number. - */ - number: SinonMatcher; - /** - * Requires the value to be a String. - */ - string: SinonMatcher; - /** - * Requires the value to be an Object. - */ - object: SinonMatcher; - /** - * Requires the value to be a Function. - */ - func: SinonMatcher; - /** - * Requires the value to be a Map. - */ - map: SinonMapMatcher; - /** - * Requires the value to be a Set. - */ - set: SinonSetMatcher; - /** - * Requires the value to be an Array. - */ - array: SinonArrayMatcher; - /** - * Requires the value to be a regular expression. - */ - regexp: SinonMatcher; - /** - * Requires the value to be a Date object. - */ - date: SinonMatcher; - /** - * Requires the value to be a Symbol. - */ - symbol: SinonMatcher; - /** - * Requires the value to be in the specified array. - */ - in(allowed: any[]): SinonMatcher; - /** - * Requires the value to strictly equal ref. - */ - same(obj: any): SinonMatcher; - /** - * Requires the value to be of the given type, where type can be one of "undefined", "null", "boolean", "number", "string", "object", "function", "array", "regexp", "date" or "symbol". - */ - typeOf(type: string): SinonMatcher; - /** - * Requires the value to be an instance of the given type. - */ - instanceOf(type: any): SinonMatcher; - /** - * Requires the value to define the given property. - * The property might be inherited via the prototype chain. - * If the optional expectation is given, the value of the property is deeply compared with the expectation. - * The expectation can be another matcher. - * @param property - * @param expect - */ - has(property: string, expect?: any): SinonMatcher; - /** - * Same as sinon.match.has but the property must be defined by the value itself. Inherited properties are ignored. - * @param property - * @param expect - */ - hasOwn(property: string, expect?: any): SinonMatcher; - /** - * Requires the value to define the given propertyPath. Dot (prop.prop) and bracket (prop[0]) notations are supported as in Lodash.get. - * The propertyPath might be inherited via the prototype chain. - * If the optional expectation is given, the value at the propertyPath is deeply compared with the expectation. - * The expectation can be another matcher. - */ - hasNested(path: string, expect?: any): SinonMatcher; - /** - * Requires every element of an Array, Set or Map, or alternatively every value of an Object to match the given matcher. - */ - every(matcher: SinonMatcher): SinonMatcher; - /** - * Requires any element of an Array, Set or Map, or alternatively any value of an Object to match the given matcher. - */ - some(matcher: SinonMatcher): SinonMatcher; - } - - interface SinonSandboxConfig { - /** - * The sandbox’s methods can be injected into another object for convenience. - * The injectInto configuration option can name an object to add properties to. - */ - injectInto: object | null; - /** - * What properties to inject. - * Note that simply naming “server” here is not sufficient to have a server property show up in the target object, - * you also have to set useFakeServer to true. - */ - properties: string[]; - /** - * If set to true, the sandbox will have a clock property. - * You can optionally pass in a configuration object that follows the specification for fake timers, such as { toFake: ["setTimeout", "setInterval"] }. - */ - useFakeTimers: boolean | Partial; - /** - * If true, server and requests properties are added to the sandbox. Can also be an object to use for fake server. - * The default one is sinon.fakeServer, but if you’re using jQuery 1.3.x or some other library that does not set the XHR’s onreadystatechange handler, - * you might want to do: - */ - useFakeServer: boolean | SinonFakeServer; - } - - /** - * Stubbed type of an object with members replaced by stubs. - * - * @template TType Type being stubbed. - */ - type StubbableType = Function & { prototype: TType }; - - /** - * An instance of a stubbed object type with functions replaced by stubs. - * - * @template TType Object type being stubbed. - */ - type SinonStubbedInstance = { - [P in keyof TType]: SinonStubbedMember - }; - - /** - * Replaces a type with a Sinon stub if it's a function. - */ - type SinonStubbedMember = T extends ( - ...args: infer TArgs - ) => infer TReturnValue ? SinonStub : T; - - interface SinonFake { - /** - * Creates a basic fake, with no behavior - */ - (): SinonSpy; - /** - * Wraps an existing Function to record all interactions, while leaving it up to the func to provide the behavior. - * This is useful when complex behavior not covered by the sinon.fake.* methods is required or when wrapping an existing function or method. - */ - (fn: Function): SinonSpy; - /** - * Creates a fake that returns the val argument - * @param val Returned value - */ - returns(val: any): SinonSpy; - /** - * Creates a fake that throws an Error with the provided value as the message property. - * If an Error is passed as the val argument, then that will be the thrown value. If any other value is passed, then that will be used for the message property of the thrown Error. - * @param val Returned value or throw value if an Error - */ - throws(val: Error | string): SinonSpy; - /** - * Creates a fake that returns a resolved Promise for the passed value. - * @param val Resolved promise - */ - resolves(val: any): SinonSpy; - /** - * Creates a fake that returns a rejected Promise for the passed value. - * If an Error is passed as the value argument, then that will be the value of the promise. - * If any other value is passed, then that will be used for the message property of the Error returned by the promise. - * @param val Rejected promise - */ - rejects(val: any): SinonSpy; - /** - * fake expects the last argument to be a callback and will invoke it with the given arguments. - */ - yields(...args: any[]): SinonSpy; - /** - * fake expects the last argument to be a callback and will invoke it asynchronously with the given arguments. - */ - yieldsAsync(...args: any[]): SinonSpy; - } - - interface SinonSandbox { - /** - * A convenience reference for sinon.assert - * Since sinon@2.0.0 - */ - assert: SinonAssert; - clock: SinonFakeTimers; - requests: SinonFakeXMLHttpRequest[]; - server: SinonFakeServer; - /** - * Works exactly like sinon.spy - */ - spy: SinonSpyStatic; - /** - * Works exactly like sinon.stub. - */ - stub: SinonStubStatic; - /** - * Works exactly like sinon.mock - */ - mock: SinonMockStatic; - - /** - * * No param : Causes Sinon to replace the global setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate, process.hrtime, performance.now(when available) - * and Date with a custom implementation which is bound to the returned clock object. - * Starts the clock at the UNIX epoch (timestamp of 0). - * * Now : As above, but rather than starting the clock with a timestamp of 0, start at the provided timestamp now. - * Since sinon@2.0.0 - * You can also pass in a Date object, and its getTime() will be used for the starting timestamp. - * * Config : As above, but allows further configuration options, some of which are: - * * config.now - Number/Date - installs lolex with the specified unix epoch (default: 0) - * * config.toFake - String[ ] - an array with explicit function names to fake. - * By default lolex will automatically fake all methods except process.nextTick. You could, however, still fake nextTick by providing it explicitly - * * config.shouldAdvanceTime - Boolean - tells lolex to increment mocked time automatically based on the real system time shift (default: false) - * * Please visit the lolex.install documentation for the full feature set. - * * Important note: when faking nextTick, normal calls to process.nextTick() would not execute automatically as they would during normal event-loop phases. - * You would have to call either clock.next(), clock.tick(), clock.runAll() or clock.runToLast() (see example below). Please refer to the lolex documentation for more information. - * @param config - */ - useFakeTimers( - config?: number | Date | Partial - ): SinonFakeTimers; - /** - * Causes Sinon to replace the native XMLHttpRequest object in browsers that support it with a custom implementation which does not send actual requests. - * In browsers that support ActiveXObject, this constructor is replaced, and fake objects are returned for XMLHTTP progIds. - * Other progIds, such as XMLDOM are left untouched. - * The native XMLHttpRequest object will be available at sinon.xhr.XMLHttpRequest - */ - useFakeXMLHttpRequest(): SinonFakeXMLHttpRequestStatic; - /** - * Fakes XHR and binds a server object to the sandbox such that it too is restored when calling sandbox.restore(). - * Access requests through sandbox.requests and server through sandbox.server - */ - useFakeServer(): SinonFakeServer; - /** - * Restores all fakes created through sandbox. - */ - restore(): void; - /** - * Resets the internal state of all fakes created through sandbox. - */ - reset(): void; - /** - * Resets the history of all stubs created through the sandbox. - * Since sinon@2.0.0 - */ - resetHistory(): void; - /** - * Resets the behaviour of all stubs created through the sandbox. - * Since sinon@2.0.0 - */ - resetBehavior(): void; - /** - * Causes all stubs created from the sandbox to return promises using a specific Promise library instead of the global one when using stub.rejects or stub.resolves. - * Returns the stub to allow chaining. - * Since sinon@2.0.0 - */ - usingPromise(promiseLibrary: any): SinonSandbox; - /** - * Verifies all mocks created through the sandbox. - */ - verify(): void; - /** - * Verifies all mocks and restores all fakes created through the sandbox. - */ - verifyAndRestore(): void; - - /** - * Replaces property on object with replacement argument. Attempts to replace an already replaced value cause an exception. - * replacement can be any value, including spies, stubs and fakes. - * This method only works on non-accessor properties, for replacing accessors, use sandbox.replaceGetter() and sandbox.replaceSetter(). - */ - replace( - obj: T, - prop: TKey, - replacement: T[TKey] - ): T[TKey]; - /** - * Replaces getter for property on object with replacement argument. Attempts to replace an already replaced getter cause an exception. - * replacement must be a Function, and can be instances of spies, stubs and fakes. - * @param obj - * @param prop - * @param replacement - */ - replaceGetter( - obj: T, - prop: TKey, - replacement: () => T[TKey] - ): () => T[TKey]; - /** - * Replaces setter for property on object with replacement argument. Attempts to replace an already replaced setter cause an exception. - * replacement must be a Function, and can be instances of spies, stubs and fakes. - * @param obj - * @param prop - * @param replacement - */ - replaceSetter( - obj: T, - prop: TKey, - replacement: (val: T[TKey]) => void - ): (val: T[TKey]) => void; - - /** - * Creates a new object with the given functions as the prototype and stubs all implemented functions. - * - * @template TType Type being stubbed. - * @param constructor Object or class to stub. - * @param overrides An optional map overriding created stubs - * @returns A stubbed version of the constructor. - * @remarks The given constructor function is not invoked. See also the stub API. - */ - createStubInstance( - constructor: StubbableType, - overrides?: { [K in keyof TType]?: - SinonStubbedMember | (TType[K] extends (...args: any[]) => infer R ? R : TType[K]) } - ): SinonStubbedInstance; - } - - interface SinonApi { - fake: SinonFake; - match: SinonMatch; - spyCall(...args: any[]): SinonSpyCall; - expectation: SinonExpectationStatic; - - clock: { - create(now: number | Date): SinonFakeTimers; - }; - - FakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic; - - fakeServer: SinonFakeServerStatic; - fakeServerWithClock: SinonFakeServerStatic; - - /** - * Creates a new sandbox object with spies, stubs, and mocks. - * @param config - */ - createSandbox(config?: Partial): SinonSandbox; - defaultConfig: Partial; - } - - interface LegacySandbox { - sandbox: { - /** - * @deprecated Since 5.0, use `sinon.createSandbox` instead - */ - create(config?: Partial): SinonSandbox; - }; - } - - type SinonStatic = SinonSandbox & LegacySandbox & SinonApi; -} - -declare const Sinon: Sinon.SinonStatic; - -export = Sinon; -export as namespace sinon; diff --git a/package-lock.json b/package-lock.json index 19d05ba493..0e239bad5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "@types/nock": "^11.1.0", "@types/node": "^12.0.4", "@types/semver": "^7.2.0", - "@types/sinon": "^7.2.0", + "@types/sinon": "^10.0.2", "@typescript-eslint/parser": "^4.1.0", "ava": "3.8.1", "eslint": "^7.9.0", @@ -546,9 +546,22 @@ } }, "node_modules/@types/sinon": { - "version": "7.5.2", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.2.tgz", + "integrity": "sha512-BHn8Bpkapj8Wdfxvh2jWIUoaYB/9/XhsL0oOvBfRagJtKlSl9NWPcFOz2lRukI9szwGxFtYZCTejJSqsGDbdmw==", "dev": true, - "license": "MIT" + "dependencies": { + "@sinonjs/fake-timers": "^7.1.0" + } + }, + "node_modules/@types/sinon/node_modules/@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^1.7.0" + } }, "node_modules/@types/tmp": { "version": "0.1.0", @@ -6159,8 +6172,24 @@ } }, "@types/sinon": { - "version": "7.5.2", - "dev": true + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.2.tgz", + "integrity": "sha512-BHn8Bpkapj8Wdfxvh2jWIUoaYB/9/XhsL0oOvBfRagJtKlSl9NWPcFOz2lRukI9szwGxFtYZCTejJSqsGDbdmw==", + "dev": true, + "requires": { + "@sinonjs/fake-timers": "^7.1.0" + }, + "dependencies": { + "@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + } + } }, "@types/tmp": { "version": "0.1.0" @@ -9380,9 +9409,6 @@ "tslib": "^1.8.1" } }, - "tunnel": { - "version": "0.0.6" - }, "type-check": { "version": "0.4.0", "dev": true, diff --git a/package.json b/package.json index 74db94611b..fad2506758 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@types/nock": "^11.1.0", "@types/node": "^12.0.4", "@types/semver": "^7.2.0", - "@types/sinon": "^7.2.0", + "@types/sinon": "^10.0.2", "@typescript-eslint/parser": "^4.1.0", "ava": "3.8.1", "eslint": "^7.9.0", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy