diff --git a/src/react/ScopeProvider.test.tsx b/src/react/ScopeProvider.test.tsx
index e622fca..bf78f1e 100644
--- a/src/react/ScopeProvider.test.tsx
+++ b/src/react/ScopeProvider.test.tsx
@@ -1,4 +1,4 @@
-import { act, renderHook } from "@testing-library/react";
+import { act, render, renderHook } from "@testing-library/react";
import {
Atom,
PrimitiveAtom,
@@ -475,4 +475,69 @@ strictModeSuite(({ wrapper: Outer, isStrict }) => {
userLifecycle.expectToMatchCalls(["jeffrey@example.com"]);
}
});
+
+ describe("Issue #64 - Peer providers don't share a value", () => {
+ const Wrapper = ({ children }: { children?: React.ReactNode }) => (
+ {children}
+ );
+
+ const Nested = molecule(() => use(UserMolecule));
+
+ const NestedComponent = () => (
+
{useMolecule(Nested).example}
+ );
+ const NonNestedComponent = () => (
+ {useMolecule(UserMolecule).example}
+ );
+
+ test.each([{ tcase: "nested" }, { tcase: "direct" }])(
+ "Should render when $tcase is first",
+ async ({ tcase }) => {
+ userLifecycle.expectUncalled();
+
+ const result = render(
+ tcase === "nested" ? (
+ <>
+
+
+
+
+
+
+ >
+ ) : (
+ <>
+
+
+
+
+
+
+ >
+ ),
+ {
+ wrapper: Wrapper,
+ },
+ );
+
+ // if (isStrict) {
+ // userLifecycle.expectCalledTimesEach(1, 2, 1);
+ // } else {
+ // userLifecycle.expectCalledTimesEach(1, 1, 0);
+ // }
+
+ const a = await result.findByTestId("nested");
+ const b = await result.findByTestId("non-nested");
+ expect(a.innerText).toBe(b.innerText);
+ result.unmount();
+
+ // if (isStrict) {
+ // userLifecycle.expectCalledTimesEach(1, 2, 2);
+ // } else {
+ // userLifecycle.expectCalledTimesEach(1, 1, 1);
+ // userLifecycle.expectToMatchCalls(["bob"]);
+ // }
+ },
+ );
+ });
});