Skip to content

Commit

Permalink
test: add test case for isDeepRef
Browse files Browse the repository at this point in the history
  • Loading branch information
Evobaso-J committed Mar 19, 2024
1 parent a2948f7 commit d7ec871
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/isDeepRef.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,16 @@ describe('isDeepRef', () => {

expect(isDeepRef(item)).toBe(true)
})
it('should return false for an object with a dynamic circular reference', () => {
const testObject = {}
Object.defineProperty(testObject, 'circularReference', {
get: function () {
delete this.circularReference
this.circularReference = testObject
return this.circularReference
}
})
expect(() => isDeepRef(testObject)).not.toThrow()
expect(isDeepRef(testObject)).toBe(false)
})
})

0 comments on commit d7ec871

Please sign in to comment.