diff --git a/tests/vanilla/store.test.tsx b/tests/vanilla/store.test.tsx index 7202851f1d..2c843541a6 100644 --- a/tests/vanilla/store.test.tsx +++ b/tests/vanilla/store.test.tsx @@ -1123,6 +1123,24 @@ it('recomputes dependents of unmounted atoms', () => { expect(bRead).not.toHaveBeenCalled() }) +it('recomputes all changed atom dependents together', async () => { + const a = atom([0]) + const b = atom([0]) + const a0 = atom((get) => get(a)[0]!) + const b0 = atom((get) => get(b)[0]!) + const a0b0 = atom((get) => [get(a0), get(b0)]) + const w = atom(null, (_, set) => { + set(a, [0]) + set(b, [1]) + }) + const store = createStore() + store.sub(a0b0, () => {}) + store.set(w) + expect(store.get(a0)).toBe(0) + expect(store.get(b0)).toBe(1) + expect(store.get(a0b0)).toEqual([0, 1]) +}) + it('should not inf on subscribe or unsubscribe', async () => { const store = createStore() const countAtom = atom(0)