From 33615be1e9acefeefb185722e175a9af19acfeaa Mon Sep 17 00:00:00 2001 From: David Maskasky Date: Fri, 15 Nov 2024 17:08:10 -0800 Subject: [PATCH] atom.write getter does not add dependencies to dependents --- tests/vanilla/store.test.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/vanilla/store.test.tsx b/tests/vanilla/store.test.tsx index 9905909ea8a..3ad51addc65 100644 --- a/tests/vanilla/store.test.tsx +++ b/tests/vanilla/store.test.tsx @@ -896,3 +896,15 @@ it('throws falsy errors in onMount, onUnmount, and listeners', () => { }) expect(() => store.set(c, 1)).toThrow('') }) + +it('does not update dependencies when accessed with write get', () => { + const store = createStore() + const a = atom(0) + const bRead = vi.fn((get) => get(a)) + const b = atom(bRead) + const w = atom(null, (get) => get(b)) + store.set(w) + bRead.mockClear() + store.set(a, 1) + expect(bRead).not.toHaveBeenCalled() // fails +})