From d7ec8716202e49d1b833cc403796da3525a86002 Mon Sep 17 00:00:00 2001 From: Evobaso-J <57828270+Evobaso-J@users.noreply.github.com> Date: Wed, 20 Mar 2024 00:02:56 +0100 Subject: [PATCH] test: add test case for isDeepRef --- tests/isDeepRef.spec.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/isDeepRef.spec.ts b/tests/isDeepRef.spec.ts index 7fc9a5b16..934c3c97d 100644 --- a/tests/isDeepRef.spec.ts +++ b/tests/isDeepRef.spec.ts @@ -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) + }) })