diff --git a/src/contrib/uri_persistence/__tests__/Recoil_Link-test.js b/src/contrib/uri_persistence/__tests__/Recoil_Link-test.js index 768646f..b6b4618 100644 --- a/src/contrib/uri_persistence/__tests__/Recoil_Link-test.js +++ b/src/contrib/uri_persistence/__tests__/Recoil_Link-test.js @@ -71,7 +71,9 @@ test('Link - snapshot', async () => { 'https://test.com/test?atom=%22MAP', ); - Simulate.click(c.children[0], {button: 0}); + act(() => { + Simulate.click(c.children[0], {button: 0}); + }); await flushPromisesAndTimers(); expect(c.textContent).toEqual('"MAP"LINK-MAP'); }); @@ -95,7 +97,9 @@ test('Link - stateChange', async () => { 'https://test.com/test?atom=%22MAP', ); - Simulate.click(c.children[0], {button: 0}); + act(() => { + Simulate.click(c.children[0], {button: 0}); + }); await flushPromisesAndTimers(); expect(c.textContent).toEqual('"MAP"LINK'); }); @@ -120,7 +124,9 @@ test('Link - state update', async () => { 'https://test.com/test?atom=%22MAP%20SET', ); - Simulate.click(c.children[0], {button: 0}); + act(() => { + Simulate.click(c.children[0], {button: 0}); + }); await flushPromisesAndTimers(); expect(c.textContent).toEqual('"MAP SET"LINK'); }); diff --git a/src/hooks/__tests__/Recoil_useRecoilBridgeAcrossReactRoots-test.js b/src/hooks/__tests__/Recoil_useRecoilBridgeAcrossReactRoots-test.js index 7ba1312..b1f6f07 100644 --- a/src/hooks/__tests__/Recoil_useRecoilBridgeAcrossReactRoots-test.js +++ b/src/hooks/__tests__/Recoil_useRecoilBridgeAcrossReactRoots-test.js @@ -36,52 +36,53 @@ const testRecoil = getRecoilTestFn(() => { useRecoilBridgeAcrossReactRoots = require('../Recoil_useRecoilBridgeAcrossReactRoots'); }); -testRecoil('useRecoilBridgeAcrossReactRoots - create a context bridge', () => { - const myAtom = atom({ - key: 'useRecoilBridgeAcrossReactRoots - context bridge', - default: 'DEFAULT', - }); +testRecoil( + 'useRecoilBridgeAcrossReactRoots - create a context bridge', + async () => { + const myAtom = atom({ + key: 'useRecoilBridgeAcrossReactRoots - context bridge', + default: 'DEFAULT', + }); - function initializeState({set, getLoadable}) { - expect(getLoadable(myAtom).contents).toEqual('DEFAULT'); - set(myAtom, 'INITIALIZE'); - expect(getLoadable(myAtom).contents).toEqual('INITIALIZE'); - } + function initializeState({set, getLoadable}) { + expect(getLoadable(myAtom).contents).toEqual('DEFAULT'); + set(myAtom, 'INITIALIZE'); + expect(getLoadable(myAtom).contents).toEqual('INITIALIZE'); + } - const [ReadWriteAtom, setAtom] = componentThatReadsAndWritesAtom(myAtom); + const [ReadWriteAtom, setAtom] = componentThatReadsAndWritesAtom(myAtom); - function NestedReactRoot({children}) { - const ref = useRef(); - const RecoilBridge = useRecoilBridgeAcrossReactRoots(); + function NestedReactRoot({children}) { + const ref = useRef(); + const RecoilBridge = useRecoilBridgeAcrossReactRoots(); - useEffect(() => { - act(() => { + useEffect(() => { ReactDOM.render( {children}, ref.current ?? document.createElement('div'), ); - }); - }, [children]); + }, [children]); - return
; - } + return
; + } - const container = document.createElement('div'); - act(() => { - ReactDOM.render( - - - - + const container = document.createElement('div'); + await act(() => { + ReactDOM.render( + - - , - container, - ); - }); - expect(container.textContent).toEqual('"INITIALIZE""INITIALIZE"'); + + + + , + container, + ); + }); - act(() => setAtom('SET')); - expect(container.textContent).toEqual('"SET""SET"'); -}); + expect(container.textContent).toEqual('"INITIALIZE""INITIALIZE"'); + + act(() => setAtom('SET')); + expect(container.textContent).toEqual('"SET""SET"'); + }, +);