Skip to content

Commit

Permalink
fix: class instance is fine since not own prop
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 6, 2024
1 parent d2cda83 commit 164cb70
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion packages/mocker/src/automocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function mockObject(
const type = getType(value)
const isFunction
= type.includes('Function') && typeof value === 'function'
if (isFunction && !value._isMockFunction) {
if (isFunction) {
// mock and delegate calls to original prototype method, which should be also mocked already
const original = this[key]
const mock = spyOn(this, key as string)
Expand Down
5 changes: 0 additions & 5 deletions packages/spy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,11 @@ export function spyOn<T, K extends keyof T>(

const currentStub = getSpy(obj, method, accessType)
if (currentStub) {
// TODO: should we reset?
return currentStub
}

const stub = tinyspy.internalSpyOn(obj, objMethod as any)

// if (vitestSpy in stub) {
// return stub as any as MockInstance
// }

return enhanceSpy(stub) as MockInstance
}

Expand Down

0 comments on commit 164cb70

Please sign in to comment.