@fluffy-spoon/substitute
Advanced tools
Comparing version 1.138.0 to 1.139.0
@@ -1,3 +0,3 @@ | ||
import { ContextState } from "./states/ContextState"; | ||
import { InitialState } from "./states/InitialState"; | ||
import { ContextState } from './states/ContextState'; | ||
import { InitialState } from './states/InitialState'; | ||
export declare class Context { | ||
@@ -15,5 +15,5 @@ private _initialState; | ||
rootGet(_target: any, property: PropertyKey): any; | ||
apply(_target: any, _this: any, args: any[]): any; | ||
set(_target: any, property: PropertyKey, value: any): void; | ||
get(_target: any, property: PropertyKey): any; | ||
getStateApply(_target: any, _this: any, args: any[]): any; | ||
setStateSet(_target: any, property: PropertyKey, value: any): void; | ||
getStateGet(_target: any, property: PropertyKey): any; | ||
get proxy(): any; | ||
@@ -20,0 +20,0 @@ get rootProxy(): any; |
@@ -16,5 +16,5 @@ "use strict"; | ||
this._proxy = new Proxy(SubstituteBase_1.SubstituteJS, { | ||
apply: (_target, _this, args) => this.apply(_target, _this, args), | ||
set: (_target, property, value) => (this.set(_target, property, value), true), | ||
get: (_target, property) => this._filterAndReturnProperty(_target, property, this.get) | ||
apply: (_target, _this, args) => this.getStateApply(_target, _this, args), | ||
set: (_target, property, value) => (this.setStateSet(_target, property, value), true), | ||
get: (_target, property) => this._filterAndReturnProperty(_target, property, this.getStateGet) | ||
}); | ||
@@ -28,3 +28,3 @@ this._rootProxy = new Proxy(SubstituteBase_1.SubstituteJS, { | ||
apply: (_target, _this, args) => this._receivedState === void 0 ? void 0 : this._receivedState.apply(this, args), | ||
set: (_target, property, value) => (this.set(_target, property, value), true), | ||
set: (_target, property, value) => (this.setStateSet(_target, property, value), true), | ||
get: (_target, property) => { | ||
@@ -34,3 +34,3 @@ const state = this.initialState.getPropertyStates.find(getPropertyState => getPropertyState.property === property); | ||
return this.handleNotFoundState(property); | ||
if (!state.functionState) | ||
if (!state.isFunctionState) | ||
state.get(this, property); | ||
@@ -42,3 +42,3 @@ this._receivedState = state; | ||
} | ||
_filterAndReturnProperty(target, property, defaultGet) { | ||
_filterAndReturnProperty(target, property, getToExecute) { | ||
switch (property) { | ||
@@ -63,3 +63,3 @@ case 'constructor': | ||
target.prototype.lastRegisteredSubstituteJSMethodOrProperty = property.toString(); | ||
return defaultGet.bind(this)(target, property); | ||
return getToExecute.bind(this)(target, property); | ||
} | ||
@@ -69,3 +69,3 @@ } | ||
if (this.initialState.hasExpectations && this.initialState.expectedCount !== null) { | ||
this.initialState.assertCallCountMatchesExpectations([], 0, Utilities_1.Type.property, property, []); | ||
this.initialState.assertCallCountMatchesExpectations([], 0, Utilities_1.PropertyType.property, property, []); | ||
return this.receivedProxy; | ||
@@ -78,9 +78,9 @@ } | ||
} | ||
apply(_target, _this, args) { | ||
getStateApply(_target, _this, args) { | ||
return this._getState.apply(this, args); | ||
} | ||
set(_target, property, value) { | ||
setStateSet(_target, property, value) { | ||
return this._setState.set(this, property, value); | ||
} | ||
get(_target, property) { | ||
getStateGet(_target, property) { | ||
if (property === Substitute_1.HandlerKey) { | ||
@@ -87,0 +87,0 @@ return this; |
import { Context } from "../Context"; | ||
import { FunctionState } from "./FunctionState"; | ||
export declare type PropertyKey = string | number | symbol; | ||
export interface ContextState { | ||
onSwitchedTo?(context: Context): void; | ||
apply(context: Context, args: any[], matchingFunctionStates?: FunctionState[]): any; | ||
apply(context: Context, args: any[]): any; | ||
set(context: Context, property: PropertyKey, value: any): void; | ||
get(context: Context, property: PropertyKey): any; | ||
} |
@@ -1,19 +0,21 @@ | ||
import { ContextState, PropertyKey } from "./ContextState"; | ||
import { Context } from "../Context"; | ||
import { FunctionState } from "./FunctionState"; | ||
import { ContextState, PropertyKey } from './ContextState'; | ||
import { Context } from '../Context'; | ||
export declare class GetPropertyState implements ContextState { | ||
private _property; | ||
private returns; | ||
private mimicks; | ||
private throws; | ||
private _callCount; | ||
private _functionState?; | ||
private get isFunction(); | ||
get property(): string | number | symbol; | ||
private _mocks; | ||
private _recordedCalls; | ||
private _isFunctionState; | ||
private _lastArgs?; | ||
get property(): PropertyKey; | ||
get isFunctionState(): boolean; | ||
get callCount(): number; | ||
get functionState(): FunctionState | undefined; | ||
constructor(_property: PropertyKey); | ||
private getCallCount; | ||
private applySubstituteMethodLogic; | ||
private processProperty; | ||
apply(context: Context, args: any[]): any; | ||
set(context: Context, property: PropertyKey, value: any): void; | ||
private isSubstituteMethod; | ||
private sanitizeSubstituteMockInputs; | ||
get(context: Context, property: PropertyKey): any; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GetPropertyState = void 0; | ||
const FunctionState_1 = require("./FunctionState"); | ||
const Utilities_1 = require("../Utilities"); | ||
@@ -10,76 +9,94 @@ const SubstituteBase_1 = require("../SubstituteBase"); | ||
this._property = _property; | ||
this.returns = Utilities_1.Nothing; | ||
this.mimicks = Utilities_1.Nothing; | ||
this.throws = Utilities_1.Nothing; | ||
this._callCount = 0; | ||
this._mocks = []; | ||
this._recordedCalls = []; | ||
this._isFunctionState = false; | ||
} | ||
get isFunction() { | ||
return !!this._functionState; | ||
} | ||
get property() { | ||
return this._property; | ||
} | ||
get isFunctionState() { | ||
return this._isFunctionState; | ||
} | ||
get callCount() { | ||
return this._callCount; | ||
return this._recordedCalls.length; | ||
} | ||
get functionState() { | ||
return this._functionState; | ||
getCallCount(args) { | ||
const callFilter = (recordedCall) => Utilities_1.areArgumentArraysEqual(recordedCall, args); | ||
return this._recordedCalls.filter(callFilter).length; | ||
} | ||
applySubstituteMethodLogic(substituteMethod, mockValue, args) { | ||
switch (substituteMethod) { | ||
case Utilities_1.SubstituteMethods.resolves: | ||
return Promise.resolve(mockValue); | ||
case Utilities_1.SubstituteMethods.rejects: | ||
return Promise.reject(mockValue); | ||
case Utilities_1.SubstituteMethods.returns: | ||
return mockValue; | ||
case Utilities_1.SubstituteMethods.throws: | ||
throw mockValue; | ||
case Utilities_1.SubstituteMethods.mimicks: | ||
return mockValue.apply(mockValue, args); | ||
default: | ||
throw SubstituteBase_1.SubstituteException.generic(`Method ${substituteMethod} not implemented`); | ||
} | ||
} | ||
processProperty(context, args, propertyType) { | ||
const hasExpectations = context.initialState.hasExpectations; | ||
if (!hasExpectations) { | ||
this._recordedCalls.push(args); | ||
const foundSubstitute = this._mocks.find(mock => Utilities_1.areArgumentArraysEqual(mock.arguments, args)); | ||
if (foundSubstitute !== void 0) { | ||
const mockValue = foundSubstitute.mockValues.length > 1 ? | ||
foundSubstitute.mockValues.shift() : | ||
foundSubstitute.mockValues[0]; | ||
return this.applySubstituteMethodLogic(foundSubstitute.substituteType, mockValue, args); | ||
} | ||
} | ||
context.initialState.assertCallCountMatchesExpectations(this._recordedCalls, this.getCallCount(args), propertyType, this.property, args); | ||
return context.proxy; | ||
} | ||
apply(context, args) { | ||
this._callCount = 0; | ||
if (this.functionState) { | ||
context.state = this.functionState; | ||
return this.functionState.apply(context, args); | ||
if (!this._isFunctionState) { | ||
this._isFunctionState = true; | ||
this._recordedCalls = []; | ||
} | ||
var functionState = new FunctionState_1.FunctionState(this); | ||
context.state = functionState; | ||
this._functionState = functionState; | ||
return context.apply(void 0, void 0, args); | ||
this._lastArgs = args; | ||
return this.processProperty(context, args, Utilities_1.PropertyType.method); | ||
} | ||
set(context, property, value) { } | ||
isSubstituteMethod(property) { | ||
return property === Utilities_1.SubstituteMethods.returns || | ||
property === Utilities_1.SubstituteMethods.mimicks || | ||
property === Utilities_1.SubstituteMethods.throws || | ||
property === Utilities_1.SubstituteMethods.resolves || | ||
property === Utilities_1.SubstituteMethods.rejects; | ||
} | ||
sanitizeSubstituteMockInputs(mockInputs) { | ||
if (mockInputs.length === 0) | ||
return [undefined]; | ||
return mockInputs.length > 1 ? | ||
[...mockInputs, undefined] : | ||
[...mockInputs]; | ||
} | ||
get(context, property) { | ||
const hasExpectations = context.initialState.hasExpectations; | ||
if (property === 'then') | ||
return void 0; | ||
if (this.isFunction) | ||
return context.proxy; | ||
if (property === Utilities_1.SubstituteMethods.mimicks) { | ||
return (input) => { | ||
this.mimicks = input; | ||
this._callCount--; | ||
if (this.isSubstituteMethod(property)) { | ||
return (...inputs) => { | ||
const mockInputs = this.sanitizeSubstituteMockInputs(inputs); | ||
const args = this._isFunctionState ? this._lastArgs : []; | ||
if (args === void 0) | ||
throw SubstituteBase_1.SubstituteException.generic('Eh, there\'s a bug, no args recorded :/'); | ||
this._mocks.push({ | ||
arguments: args, | ||
mockValues: mockInputs, | ||
substituteType: property | ||
}); | ||
this._recordedCalls.pop(); | ||
context.state = context.initialState; | ||
}; | ||
} | ||
if (property === Utilities_1.SubstituteMethods.returns) { | ||
if (this.returns !== Utilities_1.Nothing) | ||
throw SubstituteBase_1.SubstituteException.generic('The return value for the property ' + this._property.toString() + ' has already been set to ' + this.returns); | ||
return (...returns) => { | ||
this.returns = returns; | ||
this._callCount--; | ||
context.state = context.initialState; | ||
}; | ||
} | ||
if (property === Utilities_1.SubstituteMethods.throws) { | ||
return (callback) => { | ||
this.throws = callback; | ||
this._callCount--; | ||
context.state = context.initialState; | ||
}; | ||
} | ||
if (!hasExpectations) { | ||
this._callCount++; | ||
if (this.mimicks !== Utilities_1.Nothing) | ||
return this.mimicks.apply(this.mimicks); | ||
if (this.throws !== Utilities_1.Nothing) | ||
throw this.throws; | ||
if (this.returns !== Utilities_1.Nothing) { | ||
var returnsArray = this.returns; | ||
if (returnsArray.length === 1) | ||
return returnsArray[0]; | ||
return returnsArray[this._callCount - 1]; | ||
} | ||
} | ||
context.initialState.assertCallCountMatchesExpectations([[]], // I'm not sure what this was supposed to mean | ||
this.callCount, Utilities_1.Type.property, this.property, []); | ||
return context.proxy; | ||
if (this._isFunctionState) | ||
return context.proxy; | ||
return this.processProperty(context, [], Utilities_1.PropertyType.property); | ||
} | ||
@@ -86,0 +103,0 @@ } |
@@ -1,6 +0,6 @@ | ||
import { ContextState, PropertyKey } from "./ContextState"; | ||
import { Context } from "../Context"; | ||
import { GetPropertyState } from "./GetPropertyState"; | ||
import { SetPropertyState } from "./SetPropertyState"; | ||
import { Call, Type } from "../Utilities"; | ||
import { ContextState, PropertyKey } from './ContextState'; | ||
import { Context } from '../Context'; | ||
import { GetPropertyState } from './GetPropertyState'; | ||
import { SetPropertyState } from './SetPropertyState'; | ||
import { Call, PropertyType } from '../Utilities'; | ||
export declare class InitialState implements ContextState { | ||
@@ -11,3 +11,3 @@ private recordedGetPropertyStates; | ||
private _areProxiesDisabled; | ||
get expectedCount(): number; | ||
get expectedCount(): number | undefined | null; | ||
get hasExpectations(): boolean; | ||
@@ -19,5 +19,3 @@ get setPropertyStates(): SetPropertyState[]; | ||
constructor(); | ||
assertCallCountMatchesExpectations(receivedCalls: Call[], // list of arguments | ||
receivedCount: number, type: Type, // method or property | ||
propertyValue: PropertyKey, args: any[]): void; | ||
assertCallCountMatchesExpectations(receivedCalls: Call[], receivedCount: number, type: PropertyType, propertyValue: PropertyKey, args: any[]): void | never; | ||
private doesCallCountMatchExpectations; | ||
@@ -29,2 +27,3 @@ apply(context: Context, args: any[]): void; | ||
onSwitchedTo(): void; | ||
handleGet(context: Context, property: PropertyKey): any; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InitialState = void 0; | ||
const GetPropertyState_1 = require("./GetPropertyState"); | ||
const SetPropertyState_1 = require("./SetPropertyState"); | ||
@@ -16,4 +17,2 @@ const Utilities_1 = require("../Utilities"); | ||
get expectedCount() { | ||
// expected count of calls, | ||
// being assigned with received() method call | ||
return this._expectedCount; | ||
@@ -36,5 +35,3 @@ } | ||
} | ||
assertCallCountMatchesExpectations(receivedCalls, // list of arguments | ||
receivedCount, type, // method or property | ||
propertyValue, args) { | ||
assertCallCountMatchesExpectations(receivedCalls, receivedCount, type, propertyValue, args) { | ||
const expectedCount = this._expectedCount; | ||
@@ -63,3 +60,2 @@ this.clearExpectations(); | ||
const existingSetState = this.recordedSetPropertyStates.find(x => x.arguments[0] === value); | ||
; | ||
if (existingSetState) { | ||
@@ -69,5 +65,5 @@ return existingSetState.set(context, property, value); | ||
const setPropertyState = new SetPropertyState_1.SetPropertyState(property, value); | ||
setPropertyState.set(context, property, value); | ||
this.recordedSetPropertyStates.push(setPropertyState); | ||
context.state = setPropertyState; | ||
this.recordedSetPropertyStates.push(setPropertyState); | ||
return context.setStateSet(context, property, value); | ||
} | ||
@@ -80,3 +76,3 @@ get(context, property) { | ||
return (count) => { | ||
this._expectedCount = count === void 0 ? null : count; | ||
this._expectedCount = count !== null && count !== void 0 ? count : null; | ||
return context.receivedProxy; | ||
@@ -90,3 +86,3 @@ }; | ||
default: | ||
return Utilities_1.Get(this, context, property); | ||
return this.handleGet(context, property); | ||
} | ||
@@ -100,4 +96,15 @@ } | ||
} | ||
handleGet(context, property) { | ||
const existingGetState = this.getPropertyStates.find(state => state.property === property); | ||
if (existingGetState !== void 0) { | ||
context.state = existingGetState; | ||
return context.getStateGet(void 0, property); | ||
} | ||
const getState = new GetPropertyState_1.GetPropertyState(property); | ||
this.recordGetPropertyState(property, getState); | ||
context.state = getState; | ||
return context.getStateGet(void 0, property); | ||
} | ||
} | ||
exports.InitialState = InitialState; | ||
//# sourceMappingURL=InitialState.js.map |
@@ -1,3 +0,3 @@ | ||
import { ContextState, PropertyKey } from "./ContextState"; | ||
import { Context } from "../Context"; | ||
import { ContextState, PropertyKey } from './ContextState'; | ||
import { Context } from '../Context'; | ||
export declare class SetPropertyState implements ContextState { | ||
@@ -4,0 +4,0 @@ private _property; |
@@ -22,3 +22,3 @@ "use strict"; | ||
apply(context) { | ||
throw SubstituteBase_1.SubstituteException.generic('Calling apply of setPropertyState is not normal behaviour, something gone wrong'); | ||
throw SubstituteBase_1.SubstituteException.generic('Calling apply of setPropertyState is not normal behaviour, something went wrong'); | ||
} | ||
@@ -35,4 +35,3 @@ set(context, property, value) { | ||
} | ||
context.initialState.assertCallCountMatchesExpectations([[]], // not sure what this was supposed to do | ||
callCount, Utilities_1.Type.property, this.property, this.arguments); | ||
context.initialState.assertCallCountMatchesExpectations([[]], callCount, Utilities_1.PropertyType.property, this.property, this.arguments); | ||
if (!hasExpectations) { | ||
@@ -43,3 +42,3 @@ this._callCount++; | ||
get(context, property) { | ||
throw SubstituteBase_1.SubstituteException.generic('Calling get of setPropertyState is not normal behaviour, something gone wrong'); | ||
throw SubstituteBase_1.SubstituteException.generic('Calling get of setPropertyState is not normal behaviour, something went wrong'); | ||
} | ||
@@ -46,0 +45,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ObjectSubstitute, OmitProxyMethods, DisabledSubstituteObject } from "./Transformations"; | ||
import { ObjectSubstitute, OmitProxyMethods, DisabledSubstituteObject } from './Transformations'; | ||
export declare const HandlerKey: unique symbol; | ||
@@ -3,0 +3,0 @@ export declare const AreProxiesDisabledKey: unique symbol; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const Context_1 = require("./Context"); | ||
const Utilities_1 = require("./Utilities"); | ||
exports.HandlerKey = Symbol(); | ||
@@ -19,3 +18,3 @@ exports.AreProxiesDisabledKey = Symbol(); | ||
return function () { | ||
thisProxy[exports.AreProxiesDisabledKey] = true; // for what reason need to do this? | ||
thisProxy[exports.AreProxiesDisabledKey] = true; | ||
const returnValue = f.call(thisExposedProxy, ...arguments); | ||
@@ -28,10 +27,10 @@ thisProxy[exports.AreProxiesDisabledKey] = false; | ||
apply: function (_target, _this, args) { | ||
return disableProxy(thisExposedProxy.apply)(...arguments); | ||
return disableProxy(thisExposedProxy.getStateApply)(...arguments); | ||
}, | ||
set: function (_target, property, value) { | ||
return disableProxy(thisExposedProxy.set)(...arguments); | ||
return disableProxy(thisExposedProxy.setStateSet)(...arguments); | ||
}, | ||
get: function (_target, property) { | ||
Utilities_1.Get(thisExposedProxy._initialState, thisExposedProxy, property); | ||
return disableProxy(thisExposedProxy.get)(...arguments); | ||
thisExposedProxy._initialState.handleGet(thisExposedProxy, property); | ||
return disableProxy(thisExposedProxy.getStateGet)(...arguments); | ||
} | ||
@@ -38,0 +37,0 @@ }); |
/// <reference types="node" /> | ||
import { inspect } from 'util'; | ||
import { Type, Call } from './Utilities'; | ||
import { PropertyType, Call } from './Utilities'; | ||
export declare class SubstituteJS { | ||
@@ -29,3 +29,3 @@ private _lastRegisteredSubstituteJSMethodOrProperty; | ||
}, property: { | ||
type: Type; | ||
type: PropertyType; | ||
value: PropertyKey; | ||
@@ -32,0 +32,0 @@ }, calls: { |
@@ -28,15 +28,16 @@ import { AllArguments } from "./Arguments"; | ||
export declare type PropertySubstitute<TReturnType> = (TReturnType & Partial<NoArgumentMockObjectMixin<TReturnType>>); | ||
declare type OneArgumentRequiredFunction<TArgs, TReturnType> = (requiredInput: TArgs, ...restInputs: TArgs[]) => TReturnType; | ||
declare type MockObjectPromise<TReturnType> = TReturnType extends Promise<infer U> ? { | ||
resolves: (...args: U[]) => void; | ||
rejects: (exception: any) => void; | ||
resolves: OneArgumentRequiredFunction<U, void>; | ||
rejects: OneArgumentRequiredFunction<any, void>; | ||
} : {}; | ||
declare type BaseMockObjectMixin<TReturnType> = MockObjectPromise<TReturnType> & { | ||
returns: (...args: TReturnType[]) => void; | ||
throws: (exception: any) => never; | ||
returns: OneArgumentRequiredFunction<TReturnType, void>; | ||
throws: OneArgumentRequiredFunction<any, never>; | ||
}; | ||
declare type NoArgumentMockObjectMixin<TReturnType> = BaseMockObjectMixin<TReturnType> & { | ||
mimicks: (func: () => TReturnType) => void; | ||
mimicks: OneArgumentRequiredFunction<() => TReturnType, void>; | ||
}; | ||
declare type MockObjectMixin<TArguments extends any[], TReturnType> = BaseMockObjectMixin<TReturnType> & { | ||
mimicks: (func: (...args: TArguments) => TReturnType) => void; | ||
mimicks: OneArgumentRequiredFunction<(...args: TArguments) => TReturnType, void>; | ||
}; | ||
@@ -55,5 +56,5 @@ export declare type ObjectSubstitute<T extends Object, K extends Object = T> = ObjectSubstituteTransformation<T> & { | ||
}; | ||
declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | ||
declare type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>; | ||
export declare type OmitProxyMethods<T extends any> = Omit<T, 'mimick' | 'received' | 'didNotReceive'>; | ||
export declare type DisabledSubstituteObject<T> = T extends ObjectSubstitute<OmitProxyMethods<infer K>, infer K> ? K : never; | ||
export {}; |
@@ -1,5 +0,3 @@ | ||
import { InitialState } from './states/InitialState'; | ||
import { Context } from './Context'; | ||
export declare type Call = any[]; | ||
export declare enum Type { | ||
export declare enum PropertyType { | ||
method = "method", | ||
@@ -17,4 +15,2 @@ property = "property" | ||
} | ||
export declare const Nothing: unique symbol; | ||
export declare type Nothing = typeof Nothing; | ||
export declare function stringifyArguments(args: any[]): string; | ||
@@ -24,2 +20,1 @@ export declare function areArgumentArraysEqual(a: any[], b: any[]): boolean; | ||
export declare function areArgumentsEqual(a: any, b: any): boolean; | ||
export declare function Get(recorder: InitialState, context: Context, property: PropertyKey): any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Get = exports.areArgumentsEqual = exports.stringifyCalls = exports.areArgumentArraysEqual = exports.stringifyArguments = exports.Nothing = exports.SubstituteMethods = exports.Type = void 0; | ||
exports.areArgumentsEqual = exports.stringifyCalls = exports.areArgumentArraysEqual = exports.stringifyArguments = exports.SubstituteMethods = exports.PropertyType = void 0; | ||
const Arguments_1 = require("./Arguments"); | ||
const GetPropertyState_1 = require("./states/GetPropertyState"); | ||
const util = require("util"); | ||
var Type; | ||
(function (Type) { | ||
Type["method"] = "method"; | ||
Type["property"] = "property"; | ||
})(Type = exports.Type || (exports.Type = {})); | ||
var PropertyType; | ||
(function (PropertyType) { | ||
PropertyType["method"] = "method"; | ||
PropertyType["property"] = "property"; | ||
})(PropertyType = exports.PropertyType || (exports.PropertyType = {})); | ||
var SubstituteMethods; | ||
@@ -23,3 +22,2 @@ (function (SubstituteMethods) { | ||
const seenObject = Symbol(); | ||
exports.Nothing = Symbol(); | ||
function stringifyArguments(args) { | ||
@@ -35,3 +33,3 @@ args = args.map(x => util.inspect(x)); | ||
} | ||
for (var i = 0; i < Math.max(b.length, a.length); i++) { | ||
for (let i = 0; i < Math.max(b.length, a.length); i++) { | ||
if (!areArgumentsEqual(b[i], a[i])) { | ||
@@ -75,5 +73,6 @@ return false; | ||
return false; | ||
if (Object.keys(a).length !== Object.keys(b).length) | ||
const objectAKeys = Object.keys(a); | ||
if (objectAKeys.length !== Object.keys(b).length) | ||
return false; | ||
for (const key in a) { | ||
for (const key of objectAKeys) { | ||
if (!deepEqual(a[key], b[key], newObjectReferences)) | ||
@@ -93,14 +92,2 @@ return false; | ||
} | ||
function Get(recorder, context, property) { | ||
const existingGetState = recorder.getPropertyStates.find(state => state.property === property); | ||
if (existingGetState) { | ||
context.state = existingGetState; | ||
return context.get(void 0, property); | ||
} | ||
const getState = new GetPropertyState_1.GetPropertyState(property); | ||
context.state = getState; | ||
recorder.recordGetPropertyState(property, getState); | ||
return context.get(void 0, property); | ||
} | ||
exports.Get = Get; | ||
//# sourceMappingURL=Utilities.js.map |
{ | ||
"name": "@fluffy-spoon/substitute", | ||
"version": "1.138.0", | ||
"version": "1.139.0", | ||
"description": "An NSubstitute port to TypeScript called substitute.js.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
107878
36
890