Skip to content

Commit

Permalink
test: fix - store - update store and receives update from channel `St…
Browse files Browse the repository at this point in the history
…oreUpdateContext`
  • Loading branch information
VldMrgnn committed Jan 1, 2025
1 parent 14a2a81 commit 9812292
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expect, it } from "../test.ts";
import { createScope, Operation, parallel, put, Result, take } from "../mod.ts";
import {
createStore,
StoreContext,
StoreUpdateContext,
updateStore,
} from "../store/mod.ts";
import { createScope, Operation, parallel, put, Result, take } from "../mod.ts";
import { describe, expect, it } from "../test.ts";

const tests = describe("store");

Expand Down Expand Up @@ -61,29 +61,25 @@ it(
dev: false,
};
createStore({ scope, initialState });

let store;
await scope.run(function* (): Operation<Result<void>[]> {
const result = yield* parallel([
function* () {
const store = yield* StoreContext;
store = yield* StoreContext;
const chan = yield* StoreUpdateContext;
const msgList = yield* chan.subscribe();
yield* msgList.next();
expect(store.getState()).toEqual({
users: { 1: { id: "1", name: "eric" }, 3: { id: "", name: "" } },
theme: "",
token: null,
dev: true,
});
},

function* () {
yield* updateStore(updateUser({ id: "1", name: "eric" }));
},
]);

return yield* result;
});
expect(store!.getState()).toEqual({
users: { 1: { id: "1", name: "eric" }, 3: { id: "", name: "" } },
dev: true,
});
},
);

Expand Down

0 comments on commit 9812292

Please sign in to comment.