Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/sinon

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/sinon - npm Package Compare versions

Comparing version 4.3.3 to 5.0.0

257

sinon/index.d.ts

@@ -1,2 +0,2 @@

// Type definitions for Sinon 4.3
// Type definitions for Sinon 5.0
// Project: http://sinonjs.org/

@@ -8,4 +8,5 @@ // Definitions by: William Sears <https://github.com/mrbigdog2u>

// James Garbutt <https://github.com/43081j>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8

@@ -21,6 +22,3 @@ // sinon uses DOM dependencies which are absent in browser-less environment like node.js

// Properties
thisValue: any;
args: any[];
exception: any;
returnValue: any;

@@ -31,2 +29,3 @@ // Methods

calledWithExactly(...args: any[]): boolean;
calledWithNew(): boolean;
calledOnceWith(...args: any[]): boolean;

@@ -52,5 +51,10 @@ calledOnceWithExactly(...args: any[]): boolean;

interface SinonSpyCall extends SinonSpyCallApi {
thisValue: any;
exception: any;
returnValue: any;
callback: Function | undefined;
lastArg: any;
calledBefore(call: SinonSpyCall): boolean;
calledAfter(call: SinonSpyCall): boolean;
calledWithNew(call: SinonSpyCall): boolean;
}

@@ -81,3 +85,2 @@

calledImmediatelyAfter(anotherSpy: SinonSpy): boolean;
calledWithNew(): boolean;
withArgs(...args: any[]): SinonSpy;

@@ -97,4 +100,2 @@ alwaysCalledOn(obj: any): boolean;

getCalls(): SinonSpyCall[];
/// @deprecated Use resetHistory() instead
reset(): void;
resetHistory(): void;

@@ -111,9 +112,5 @@ printf(format: string, ...args: any[]): string;

interface SinonStatic {
spy: SinonSpyStatic;
}
interface SinonStub extends SinonSpy {
resetBehavior(): void;
resetHistory(): void;
reset(): void;
usingPromise(promiseLibrary: any): SinonStub;

@@ -142,3 +139,3 @@

callsArgOnWithAsync(index: number, context: any, ...args: any[]): SinonStub;
callsFake(func: (...args: any[]) => void): SinonStub;
callsFake(func: (...args: any[]) => any): SinonStub;
get(func: () => any): SinonStub;

@@ -167,9 +164,4 @@ set(func: (v: any) => void): SinonStub;

<T>(obj: T, method: keyof T): SinonStub;
<T>(obj: T, method: keyof T, func: Function): SinonStub;
}
interface SinonStatic {
stub: SinonStubStatic;
}
interface SinonExpectation extends SinonStub {

@@ -205,15 +197,18 @@ atLeast(n: number): SinonExpectation;

interface SinonStatic {
expectation: SinonExpectationStatic;
mock: SinonMockStatic;
}
type SinonTimerId = number | { id: number };
interface SinonFakeTimers {
now: number;
create(now: number): SinonFakeTimers;
setTimeout(callback: (...args: any[]) => void, timeout: number, ...args: any[]): number;
clearTimeout(id: number): void;
setInterval(callback: (...args: any[]) => void, timeout: number, ...args: any[]): number;
clearInterval(id: number): void;
tick(ms: number): 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: (...args: any[]) => void): number;
cancelAnimationFrame(id: number): void;
nextTick(callback: () => void): void;
tick(ms: number | string): void;
next(): void;

@@ -223,2 +218,5 @@ runAll(): void;

reset(): void;
runMicrotasks(): void;
runToFrame(): void;
Date(): Date;

@@ -232,3 +230,5 @@ Date(year: number): Date;

Date(year: number, month: number, day: number, hour: number, minute: number, second: number, ms: number): Date;
restore(): void;
uninstall(): void;

@@ -255,12 +255,2 @@ /**

interface SinonFakeTimersStatic {
(now?: number | Date): SinonFakeTimers;
(config?: Partial<SinonFakeTimersConfig>): SinonFakeTimers;
}
interface SinonStatic {
useFakeTimers: SinonFakeTimersStatic;
clock: SinonFakeTimers;
}
interface SinonFakeUploadProgress {

@@ -281,3 +271,2 @@ eventListeners: {

// Properties
onCreate(xhr: SinonFakeXMLHttpRequest): void;
url: string;

@@ -300,4 +289,2 @@ method: string;

restore(): void;
useFilters: boolean;
addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void;
setResponseHeaders(headers: any): void;

@@ -311,7 +298,7 @@ setResponseBody(body: string): void;

type SinonFakeXMLHttpRequestStatic = () => SinonFakeXMLHttpRequest;
interface SinonStatic {
useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
FakeXMLHttpRequest: SinonFakeXMLHttpRequest;
interface SinonFakeXMLHttpRequestStatic {
new(): SinonFakeXMLHttpRequest;
useFilters: boolean;
addFilter(filter: (method: string, url: string, async: boolean, username: string, password: string) => boolean): void;
onCreate(xhr: SinonFakeXMLHttpRequest): void;
}

@@ -345,20 +332,15 @@

interface SinonFakeServerOptions {
autoRespond?: boolean;
autoRespondAfter?: number;
fakeHTTPMethods?: boolean;
respondImmediately?: boolean;
autoRespond: boolean;
autoRespondAfter: number;
fakeHTTPMethods: boolean;
respondImmediately: boolean;
}
interface SinonFakeServerStatic {
create(options?: SinonFakeServerOptions): SinonFakeServer;
create(options?: Partial<SinonFakeServerOptions>): SinonFakeServer;
}
interface SinonStatic {
fakeServer: SinonFakeServerStatic;
fakeServerWithClock: SinonFakeServerStatic;
}
interface SinonExposeOptions {
prefix?: string;
includeFail?: boolean;
prefix: string;
includeFail: boolean;
}

@@ -398,12 +380,9 @@

match(actual: any, expected: any): void;
expose(obj: any, options?: SinonExposeOptions): void;
expose(obj: any, options?: Partial<SinonExposeOptions>): void;
}
interface SinonStatic {
assert: SinonAssert;
}
interface SinonMatcher {
and(expr: SinonMatcher): SinonMatcher;
or(expr: SinonMatcher): SinonMatcher;
test(val: any): boolean;
}

@@ -464,4 +443,4 @@

(expr: RegExp): SinonMatcher;
(obj: any): SinonMatcher;
(callback: (value: any) => boolean, message?: string): SinonMatcher;
(obj: object): SinonMatcher;
any: SinonMatcher;

@@ -496,19 +475,52 @@ defined: SinonMatcher;

hasOwn(property: string, expect?: any): SinonMatcher;
hasNested(path: string, expect?: any): SinonMatcher;
every(matcher: SinonMatcher): SinonMatcher;
some(matcher: SinonMatcher): SinonMatcher;
}
interface SinonStatic {
match: SinonMatch;
interface SinonSandboxConfig {
injectInto: object | null;
properties: string[];
useFakeTimers: boolean | Partial<SinonFakeTimersConfig>;
useFakeServer: boolean | SinonFakeServer;
}
interface SinonSandboxConfig {
injectInto?: any;
properties?: string[];
useFakeTimers?: any;
useFakeServer?: any;
/**
* Stubbed type of an object with members replaced by stubs.
*
* @template TType Type being stubbed.
*/
interface StubbableType<TType> {
new(...args: any[]): TType;
}
/**
* An instance of a stubbed object type with functions replaced by stubs.
*
* @template TType Object type being stubbed.
*/
type SinonStubbedInstance<TType> = {
[P in keyof TType]: SinonStubbedMember<TType[P]>;
};
/**
* Replaces a type with a Sinon stub if it's a function.
*/
type SinonStubbedMember<T> = T extends Function ? SinonStub : T;
interface SinonFake {
(): SinonSpy;
(fn: Function): SinonSpy;
returns(val: any): SinonSpy;
throws(val: Error | string): SinonSpy;
resolves(val: any): SinonSpy;
rejects(val: any): SinonSpy;
yields(...args: any[]): SinonSpy;
yieldsAsync(...args: any[]): SinonSpy;
}
interface SinonSandbox {
assert: SinonAssert;
clock: SinonFakeTimers;
requests: SinonFakeXMLHttpRequest;
requests: SinonFakeXMLHttpRequest[];
server: SinonFakeServer;

@@ -518,4 +530,5 @@ spy: SinonSpyStatic;

mock: SinonMockStatic;
useFakeTimers: SinonFakeTimersStatic;
useFakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
useFakeTimers(config?: number | Date | Partial<SinonFakeTimersConfig>): SinonFakeTimers;
useFakeXMLHttpRequest(): SinonFakeXMLHttpRequestStatic;
useFakeServer(): SinonFakeServer;

@@ -529,42 +542,19 @@ restore(): void;

verifyAndRestore(): void;
createStubInstance(constructor: any): any;
createStubInstance<TType>(constructor: StubbableType<TType>): SinonStubbedInstance<TType>;
}
interface SinonSandboxStatic {
create(config?: SinonSandboxConfig): SinonSandbox;
}
replace<T, TKey extends keyof T>(
obj: T,
prop: TKey,
replacement: T[TKey]): T[TKey];
replaceGetter<T, TKey extends keyof T>(
obj: T,
prop: TKey,
replacement: () => T[TKey]): () => T[TKey];
replaceSetter<T, TKey extends keyof T>(
obj: T,
prop: TKey,
replacement: (val: T[TKey]) => void): (val: T[TKey]) => void;
interface SinonStatic {
createSandbox(config?: SinonSandboxConfig): SinonSandbox;
defaultConfig: SinonSandboxConfig;
sandbox: SinonSandboxStatic;
}
interface SinonTestConfig {
injectIntoThis?: boolean;
injectInto?: any;
properties?: string[];
useFakeTimers?: boolean;
useFakeServer?: boolean;
}
interface SinonTestWrapper extends SinonSandbox {
(...args: any[]): any;
}
// Utility overridables
interface SinonStatic {
/**
* Creates a new object with the given functions as the prototype and stubs all implemented functions.
*
* @param constructor Object or class to stub.
* @returns A stubbed version of the constructor.
* @remarks The given constructor function is not invoked. See also the stub API.
*/
createStubInstance(constructor: any): any;
/**
* Creates a new object with the given functions as the prototype and stubs all implemented functions.
*
* @template TType Type being stubbed.

@@ -576,26 +566,33 @@ * @param constructor Object or class to stub.

createStubInstance<TType>(constructor: StubbableType<TType>): SinonStubbedInstance<TType>;
}
format(obj: any): string;
restore(object: any): void;
interface SinonApi {
fake: SinonFake;
match: SinonMatch;
spyCall(...args: any[]): SinonSpyCall;
expectation: SinonExpectationStatic;
clock: {
create(now: number | Date): SinonFakeTimers;
};
FakeXMLHttpRequest: SinonFakeXMLHttpRequestStatic;
fakeServer: SinonFakeServerStatic;
fakeServerWithClock: SinonFakeServerStatic;
createSandbox(config?: Partial<SinonSandboxConfig>): SinonSandbox;
defaultConfig: Partial<SinonSandboxConfig>;
}
/**
* Stubbed type of an object with members replaced by stubs.
*
* @template TType Type being stubbed.
*/
interface StubbableType<TType> {
new(...args: any[]): TType;
interface LegacySandbox {
sandbox: {
/**
* @deprecated Since 5.0, use `sinon.createSandbox` instead
*/
create(config?: Partial<SinonSandboxConfig>): SinonSandbox;
};
}
/**
* An instance of a stubbed object type with members replaced by stubs.
*
* @template TType Object type being stubbed.
*/
type SinonStubbedInstance<TType> = {
// TODO: this should really only replace functions on TType with SinonStubs, not all properties
// Likely infeasible without mapped conditional types, per https://github.com/Microsoft/TypeScript/issues/12424
[P in keyof TType]: SinonStub;
};
type SinonStatic = SinonSandbox & LegacySandbox & SinonApi;
}

@@ -602,0 +599,0 @@

{
"name": "@types/sinon",
"version": "4.3.3",
"version": "5.0.0",
"description": "TypeScript definitions for Sinon",

@@ -31,2 +31,7 @@ "license": "MIT",

"githubUsername": "43081j"
},
{
"name": "Josh Goldberg",
"url": "https://github.com/joshuakgoldberg",
"githubUsername": "joshuakgoldberg"
}

@@ -41,4 +46,4 @@ ],

"dependencies": {},
"typesPublisherContentHash": "b67d8134cedc1738e4956a350bf61589807cfb97d3e393e3ee7c0c0682292942",
"typeScriptVersion": "2.3"
"typesPublisherContentHash": "6f7452ca688018dda9f23057ba059aa3e40ed23c996520cbc55cd8e5a8fadfb5",
"typeScriptVersion": "2.8"
}

@@ -11,3 +11,3 @@ # Installation

Additional Details
* Last updated: Thu, 10 May 2018 20:58:18 GMT
* Last updated: Thu, 24 May 2018 17:14:29 GMT
* Dependencies: none

@@ -17,2 +17,2 @@ * 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>.
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>.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc