From 829c2852c59839183d6384e2734220757c5485b4 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Oct 2021 13:58:37 +0200 Subject: [PATCH] test: circular references break --- test/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/index.js b/test/index.js index f1e7bf8..341ae83 100644 --- a/test/index.js +++ b/test/index.js @@ -206,3 +206,19 @@ test('explicitly use exposed variadic strategy', () => { // Teardown spy.mockRestore() }) + +test('memoize functions with circular ref', () => { + const state = {a: 'hello'} + state.b = state + + function reducer (state) { + return {...state, a: state.a + ' world'} + } + + const memoizedState = memoize(reducer) + + // Assertions + + expect(memoizedState(state)).toBe({...state, a: state.a + ' world'}) +}) +