Socket
Socket
Sign inDemoInstall

spy4js

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spy4js - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

5

package.json
{
"name": "spy4js",
"version": "2.4.0",
"version": "2.5.0",
"description": "Smart, compact and powerful spy test framework",

@@ -22,3 +22,4 @@ "main": "dist/cjs/spy.js",

"jest",
"flow"
"flow",
"TypeScript"
],

@@ -25,0 +26,0 @@ "author": "Viktor Luft <viktor.luft@freiheit.com> (https://github.com/fdc-viktor-luft)",

3

README.md

@@ -11,3 +11,4 @@ [![GitHub license][license-image]][license-url]

- `flow` support out-of-the-box
- `TypeScript` support included
- `flow` support included
- Performance

@@ -14,0 +15,0 @@ - No foreign dependencies

@@ -35,3 +35,3 @@ /**

export const createMock = (obj: Object, methods: string[]): Object => {
export const createMock = <T, K: $Keys<T>>(obj: T, methods: K[]): Object => {
const mock = registerMock(obj);

@@ -38,0 +38,0 @@ forEach(methods, (_, method: string) => {

const Comparator = (arg: unknown) => boolean;
interface SpyComparator {
compare(arg: unknown): string | undefined;
}
const Comparator = (arg: any) => boolean;
type SpyComparator = {
compare(arg: any): string | undefined;
};

@@ -10,4 +10,4 @@ const COMPARE = (comparator: Comparator) => SpyComparator;

interface SpyInstance {
(...args: unknown[]): unknown,
type SpyInstance = {
(...args: any[]): any,
configure: (config: {

@@ -18,4 +18,4 @@ useOwnEquals?: boolean,

calls: (...funcs: Function[]) => SpyInstance,
returns: (...args: unknown[]) => SpyInstance,
resolves: (...args: unknown[]) => SpyInstance,
returns: (...args: any[]) => SpyInstance,
resolves: (...args: any[]) => SpyInstance,
rejects: (...msgOrErrors: OptionalMessageOrError[]) => SpyInstance,

@@ -28,8 +28,8 @@ throws: (msgOrError: OptionalMessageOrError) => SpyInstance,

wasCalled: (callCount?: number) => undefined,
hasCallHistory: (...callHistory: Array<unknown[] | unknown>) => undefined,
hasCallHistory: (...callHistory: Array<any[] | any>) => undefined,
wasNotCalled: () => undefined,
wasCalledWith: (...args: unknown[]) => undefined,
wasNotCalledWith: (...args: unknown[]) => undefined,
getCallArguments: (callNr?: number) => unknown[],
getCallArgument: (callNr?: number, argNr?: number) => unknown,
wasCalledWith: (...args: any[]) => undefined,
wasNotCalledWith: (...args: any[]) => undefined,
getCallArguments: (callNr?: number) => any[],
getCallArgument: (callNr?: number, argNr?: number) => any,
getCallCount: () => number,

@@ -39,3 +39,3 @@ showCallArguments: (additionalInformation?: string[]) => string,

interface ISpy {
type ISpy = {
new(name: string = ''): SpyInstance;

@@ -49,12 +49,9 @@ configure(config: {

COMPARE: typeof COMPARE;
on(obj: Object, methodName: string): SpyInstance;
mock<T, K extends keyof T>(
obj: T,
...methodNames: K[]
): { [K]: SpyInstance };
on<T, K extends keyof T>(obj: T, methodName: K): SpyInstance;
mock<T, K extends keyof T>(obj: T, ...methodNames: K[]): { [P in K]: SpyInstance };
initMocks(scope?: string): undefined;
restoreAll(): undefined;
resetAll(): undefined;
}
};
export const Spy: ISpy; // want to import ISpy
export const Spy: ISpy;

@@ -756,3 +756,3 @@ /**

*/
static on(obj: Object, methodName: string): SpyInstance {
static on<T: Object>(obj: T, methodName: $Keys<T>): SpyInstance {
const method = obj[methodName];

@@ -806,6 +806,6 @@ if (!(method instanceof Function)) {

*/
static mock(
obj: Object,
...methodNames: string[]
): { [string]: SpyInstance } {
static mock<T: Object>(
obj: T,
...methodNames: $Keys<T>[]
): { [$Keys<T>]: SpyInstance } {
return createMock(obj, methodNames);

@@ -812,0 +812,0 @@ }

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