multi-store-test.diff

· erock's pastes · raw

expires: 2025-01-01

 1diff --git a/test/thunk.test.ts b/test/thunk.test.ts
 2index 1aa41ef..e1e75c8 100644
 3--- a/test/thunk.test.ts
 4+++ b/test/thunk.test.ts
 5@@ -625,3 +625,30 @@ it(
 6     );
 7   },
 8 );
 9+
10+it.only(
11+  tests,
12+  "should allow multiple stores to register a thunk",
13+  () => {
14+    const api1 = createThunks<RoboCtx>();
15+    api1.use(api1.routes());
16+
17+    const storeA = createStore({ initialState: {} });
18+    const storeB = createStore({ initialState: {} });
19+    storeA.run(api1.register);
20+    storeB.run(api1.register);
21+
22+    let acc = "";
23+    const action = api1.create("/users", function* () {
24+      acc += "b";
25+    });
26+    storeA.dispatch(action());
27+    storeB.dispatch(action());
28+
29+    asserts.assertEquals(
30+      acc,
31+      "bb",
32+      "Expected 'bb' after first API call, but got: " + acc,
33+    );
34+  },
35+);