@vitest/spy
Advanced tools
Comparing version 0.31.0 to 0.31.1
@@ -45,2 +45,9 @@ import * as tinyspy from 'tinyspy'; | ||
let implementationChangedTemporarily = false; | ||
function mockCall(...args) { | ||
instances.push(this); | ||
invocations.push(++callOrder); | ||
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => { | ||
}); | ||
return impl.apply(this, args); | ||
} | ||
let name = stub.name; | ||
@@ -66,2 +73,3 @@ stub.getMockName = () => name || "vi.fn()"; | ||
stub.mockReset(); | ||
state.restore(); | ||
implementation = void 0; | ||
@@ -73,2 +81,3 @@ return stub; | ||
implementation = fn2; | ||
state.willCall(mockCall); | ||
return stub; | ||
@@ -83,2 +92,3 @@ }; | ||
implementation = fn2; | ||
state.willCall(mockCall); | ||
implementationChangedTemporarily = true; | ||
@@ -112,9 +122,3 @@ const reset = () => { | ||
}); | ||
state.willCall(function(...args) { | ||
instances.push(this); | ||
invocations.push(++callOrder); | ||
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => { | ||
}); | ||
return impl.apply(this, args); | ||
}); | ||
state.willCall(mockCall); | ||
spies.add(stub); | ||
@@ -124,4 +128,4 @@ return stub; | ||
function fn(implementation) { | ||
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: () => { | ||
} }, "spy")); | ||
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: implementation || (() => { | ||
}) }, "spy")); | ||
if (implementation) | ||
@@ -128,0 +132,0 @@ enhancedSpy.mockImplementation(implementation); |
@@ -45,2 +45,9 @@ import * as tinyspy from 'tinyspy'; | ||
let implementationChangedTemporarily = false; | ||
function mockCall(...args) { | ||
instances.push(this); | ||
invocations.push(++callOrder); | ||
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => { | ||
}); | ||
return impl.apply(this, args); | ||
} | ||
let name = stub.name; | ||
@@ -66,2 +73,3 @@ stub.getMockName = () => name || "vi.fn()"; | ||
stub.mockReset(); | ||
state.restore(); | ||
implementation = void 0; | ||
@@ -73,2 +81,3 @@ return stub; | ||
implementation = fn2; | ||
state.willCall(mockCall); | ||
return stub; | ||
@@ -83,2 +92,3 @@ }; | ||
implementation = fn2; | ||
state.willCall(mockCall); | ||
implementationChangedTemporarily = true; | ||
@@ -112,9 +122,3 @@ const reset = () => { | ||
}); | ||
state.willCall(function(...args) { | ||
instances.push(this); | ||
invocations.push(++callOrder); | ||
const impl = implementationChangedTemporarily ? implementation : onceImplementations.shift() || implementation || state.getOriginal() || (() => { | ||
}); | ||
return impl.apply(this, args); | ||
}); | ||
state.willCall(mockCall); | ||
spies.add(stub); | ||
@@ -124,4 +128,4 @@ return stub; | ||
function fn(implementation) { | ||
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: () => { | ||
} }, "spy")); | ||
const enhancedSpy = enhanceSpy(tinyspy.internalSpyOn({ spy: implementation || (() => { | ||
}) }, "spy")); | ||
if (implementation) | ||
@@ -128,0 +132,0 @@ enhancedSpy.mockImplementation(implementation); |
{ | ||
"name": "@vitest/spy", | ||
"type": "module", | ||
"version": "0.31.0", | ||
"version": "0.31.1", | ||
"description": "Lightweight Jest compatible spy implementation", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15299
362