From f0ac257b99b87fcae85b1b3533d13257d7e132a6 Mon Sep 17 00:00:00 2001 From: Christian van der Loo Date: Wed, 21 Aug 2024 21:47:11 -0400 Subject: [PATCH 1/5] docs: update build-img and build-url --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5e6c75..d09ae7e 100644 --- a/README.md +++ b/README.md @@ -144,8 +144,8 @@ const useStore = create Date: Wed, 21 Aug 2024 22:19:02 -0400 Subject: [PATCH 2/5] docs: swap immer and computec --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b5e6c75..af06f22 100644 --- a/README.md +++ b/README.md @@ -103,22 +103,24 @@ A fully-featured example can be found under the "example" directory. Here's an example with the Immer middleware. > [!WARNING] -> Types may not be as you expect when using Immer, as it derives the SetState type from the output of GetState, where `zustand-computed` makes SetState only allow the regular Store and the GetState return both the store and the computed store. To access the ComputedStore inside Immer, you will need to assert the `Store` type as `Store & ComputedStore`. +> Immer derives the SetState type from the output of GetState, where `zustand-computed` types SetState to allow only the regular Store and types GetState to return both the store and the computed store. To avoid this issue, you may need to apply Immer outside of `zustand-computed`. If `zustand-computed` must be outside of Immer, you will need to assert the `Store` type as `Store & ComputedStore`. ```ts const useStore = create()( devtools( - computed( - immer((set) => ({ - count: 1, - inc: () => - set((state) => { - // example with Immer middleware - state.count += 1 - }), - dec: () => set((state) => ({ count: state.count - 1 })), - })), - computeState + immer( + computed( + (set) => ({ + count: 1, + inc: () => + set((state) => { + // example with Immer middleware + state.count += 1 + }), + dec: () => set((state) => ({ count: state.count - 1 })), + }), + computeState + ), ) ) ) From 46d1e63e1e832529b2511ff04adc94ce0b78435e Mon Sep 17 00:00:00 2001 From: Christian van der Loo Date: Wed, 21 Aug 2024 22:36:22 -0400 Subject: [PATCH 3/5] build(dev-deps): changeover to bun test and remove jest types --- bun.lockb | Bin 115920 -> 104840 bytes package.json | 41 +++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/bun.lockb b/bun.lockb index 650db5c0e1975633b8a588589113f230c3e857a0..5717637d62a5f6e3bcb675927f11d28aa9c2ee42 100755 GIT binary patch delta 18968 zcmeHvc~})kx_;M@qa5{!3L*&ZyU4z8=KyYCgNjCuXk1v1f+8p&f>8k{MvcL()K-l9 z7Pmx$8yI5Hn20MH*Cd*lO-+nZ6E!$7{@$+_@y*Ds=lgj zs!v%nufg21`infe*LyJcr0uW_si99<)Yb97?d|*J*Q?KM?pyY&%cMC&`&ZuleFYQf zvR`azTiCCuLgW~ssUQ?ho05~8l$k1ITa!|9Nev2(5uXKVfUHDZOUQgkJIGAPhLCyb zxmE;)6rd6Kv3g3ru{qW}Yi4dvc2-8llu3e+T3--aBRv|@wGaU}HKIABGx%?ML1+V6 z1KA03H)K1=C2D*YWJmBg$PSPmkZmFDRC(V<$$uV_;`c+kLau^zfm{G-gq)O>lUtaQ zlOtS(c@%LLk}Szg%FIen6$EQe@|5(9RACj&B#UQ5IznctGEtSiROtcP0_m+F9U$wg z@<9`YUsvS`Rqk&h6v~Pl)QAPDd=1hb1*EBRs4AmW=>^#w>1|ZmSd~v;1;yV|W!@C4 zdu~pOkYk;gXU!IbtvV%rEUZD>iV|C*|H<+}h@i0zbW#%Df<&1`{nYp{NE*`~kW@jM zl}1_+N-P zx-JhMLIo~Ii%A;c5HvLB!Kt8S;FPZ#oEi|uBkT1mEC(YO{tG1a-{$s8>I86DR8$Xc zL!NcBgW?fCfKzEnR%7@L%n>pmqrJqeup>kH^pH`J(dY>vA%KQ}um zyNg^-|Dy3ZS(#(gGpyqfL5kVdoUDvItFW-E;)=5&$&9Ix)W2y-IayOP1);i|(qGy@ z#qxL?&%*s^CiuR}ia<4?gUKN=vnDhKh@I@KErpSweQPbDEED>W%6O%T$i2r6lEAA(1^-aEMgWH>t&XM=88BB-zyrl4i(n(4)otwyJ-)m(on%-tvGH z7C9n73fAoGtZdAdZhe%3^ol~!K5%NcHp0Pum4g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Y- zEe^%yLir)grIh3np=Bm>GQ%ZQ=#a;pY`+8vnkbGK1neRsb8(TLoKPesq~6IO?5Yn} z$E3iSwBC6a^AIj(JjKT-s*sTigZmpYOH}gtIu8}U&hQkUw5T%nS5Fz794q)@RkV>A zLpmyaNqYthc@vn6R{Y5T1tJwp6IiWk;=G|X2iafJ#q+9){7{BcIRz_2Y0A|UCL5W? tuEga6G9|d}3yh4F7A8z!_S@$SXE)0TcH>y}?LUlV5o~+YiL7yj{{`_|1G)eJ diff --git a/package.json b/package.json index 7352518..b2dc9a3 100644 --- a/package.json +++ b/package.json @@ -1,33 +1,16 @@ { "name": "zustand-computed", "version": "1.4.1", - "description": "A Zustand middleware to create computed states.", "author": "chrisvander", - "license": "MIT", + "repository": "chrisvander/zustand-computed", "main": "dist/index.js", "module": "dist/index.mjs", - "exports": { - ".": { - "import": "./dist/index.js", - "require": "./dist/index.mjs" - } - }, - "repository": "chrisvander/zustand-computed", - "files": [ - "/dist" - ], - "scripts": { - "check": "biome check --write", - "format": "biome format --write", - "lint": "biome lint", - "build": "vite build" - }, "devDependencies": { "@biomejs/biome": "^1.8.3", "@commitlint/cli": "^19.4.0", "@commitlint/config-conventional": "^19.2.2", - "@tsconfig/recommended": "^1.0.7", - "@types/jest": "^29.5.12", + "@tsconfig/bun": "^1.0.7", + "@types/bun": "^1.1.6", "@types/node": "^22.5.0", "husky": "^9.1.5", "react": "^18.3.1", @@ -41,6 +24,16 @@ "react": "^18.2.0", "zustand": "^4.3.8" }, + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.mjs" + } + }, + "description": "A Zustand middleware to create computed states.", + "files": [ + "/dist" + ], "keywords": [ "zustand", "computed", @@ -52,7 +45,11 @@ "npm", "typescript" ], - "dependencies": { - "@tsconfig/bun": "^1.0.7" + "license": "MIT", + "scripts": { + "check": "biome check --write", + "format": "biome format --write", + "lint": "biome lint", + "build": "vite build" } } From 1d0d1497246c5e99fc6fbbf145e2d07b8e572ebd Mon Sep 17 00:00:00 2001 From: Christian van der Loo Date: Wed, 21 Aug 2024 22:36:30 -0400 Subject: [PATCH 4/5] test: import from bun:test --- src/computed.test.ts | 209 ++++++++++++++++++++++--------------------- 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/src/computed.test.ts b/src/computed.test.ts index 647b586..cf274fe 100644 --- a/src/computed.test.ts +++ b/src/computed.test.ts @@ -1,34 +1,35 @@ -import { type StateCreator, create } from "zustand" -import { type ComputedStateOpts, computed } from "./computed" +import { describe, expect, test, beforeEach, mock } from "bun:test"; +import { type StateCreator, create } from "zustand"; +import { type ComputedStateOpts, computed } from "./computed"; type Store = { - count: number - x: number - y: number - inc: () => void - dec: () => void -} + count: number; + x: number; + y: number; + inc: () => void; + dec: () => void; +}; type ComputedStore = { - countSq: number + countSq: number; nestedResult: { - stringified: string - } -} + stringified: string; + }; +}; function computeState(state: Store): ComputedStore { const nestedResult = { stringified: JSON.stringify(state.count), - } + }; return { countSq: state.count ** 2, nestedResult, - } + }; } describe("default config", () => { - const computeStateMock = jest.fn(computeState) + const computeStateMock = mock(computeState); const makeStore = () => create( computed( @@ -41,52 +42,52 @@ describe("default config", () => { }), computeStateMock, ), - ) + ); - let useStore: ReturnType + let useStore: ReturnType; beforeEach(() => { - jest.clearAllMocks() - useStore = makeStore() - }) + computeStateMock.mockClear(); + useStore = makeStore(); + }); test("computed works on simple counter example", () => { // note: this function should have been called once on store creation - expect(computeStateMock).toHaveBeenCalledTimes(1) - expect(useStore.getState().count).toEqual(1) - expect(useStore.getState().countSq).toEqual(1) - useStore.getState().inc() - expect(useStore.getState().count).toEqual(2) - expect(useStore.getState().countSq).toEqual(4) - useStore.getState().dec() - expect(useStore.getState().count).toEqual(1) - expect(useStore.getState().countSq).toEqual(1) - useStore.setState({ count: 4 }) - expect(useStore.getState().countSq).toEqual(16) - expect(computeStateMock).toHaveBeenCalledTimes(4) - }) + expect(computeStateMock).toHaveBeenCalledTimes(1); + expect(useStore.getState().count).toEqual(1); + expect(useStore.getState().countSq).toEqual(1); + useStore.getState().inc(); + expect(useStore.getState().count).toEqual(2); + expect(useStore.getState().countSq).toEqual(4); + useStore.getState().dec(); + expect(useStore.getState().count).toEqual(1); + expect(useStore.getState().countSq).toEqual(1); + useStore.setState({ count: 4 }); + expect(useStore.getState().countSq).toEqual(16); + expect(computeStateMock).toHaveBeenCalledTimes(4); + }); test("computed does not modify object ref even after change", () => { - useStore.setState({ count: 4 }) - expect(useStore.getState().count).toEqual(4) - const obj = useStore.getState().nestedResult - useStore.setState({ count: 4 }) - const toCompare = useStore.getState().nestedResult - expect(obj).toEqual(toCompare) - }) + useStore.setState({ count: 4 }); + expect(useStore.getState().count).toEqual(4); + const obj = useStore.getState().nestedResult; + useStore.setState({ count: 4 }); + const toCompare = useStore.getState().nestedResult; + expect(obj).toEqual(toCompare); + }); test("modifying variables x and y do not trigger compute function more than once, as they are not used in compute function", () => { - expect(computeStateMock).toHaveBeenCalledTimes(1) - useStore.setState({ x: 2 }) - expect(computeStateMock).toHaveBeenCalledTimes(2) - useStore.setState({ x: 3 }) - expect(computeStateMock).toHaveBeenCalledTimes(2) - useStore.setState({ y: 2 }) - expect(computeStateMock).toHaveBeenCalledTimes(2) - }) -}) + expect(computeStateMock).toHaveBeenCalledTimes(1); + useStore.setState({ x: 2 }); + expect(computeStateMock).toHaveBeenCalledTimes(2); + useStore.setState({ x: 3 }); + expect(computeStateMock).toHaveBeenCalledTimes(2); + useStore.setState({ y: 2 }); + expect(computeStateMock).toHaveBeenCalledTimes(2); + }); +}); describe("custom config", () => { - const computeStateMock = jest.fn(computeState) + const computeStateMock = mock(computeState); const makeStore = (opts?: ComputedStateOpts) => create( computed( @@ -100,54 +101,54 @@ describe("custom config", () => { computeStateMock, opts, ), - ) + ); beforeEach(() => { - computeStateMock.mockClear() - }) + computeStateMock.mockClear(); + }); test("computed does not update when a custom key selector is given", () => { - const useStore = makeStore({ keys: ["x", "y"] }) + const useStore = makeStore({ keys: ["x", "y"] }); // because we only care about x and y, the compute function should not be called when count changes - expect(computeStateMock).toHaveBeenCalledTimes(1) - expect(useStore.getState().count).toEqual(1) - expect(useStore.getState().countSq).toEqual(1) - useStore.getState().inc() - expect(useStore.getState().count).toEqual(2) - expect(useStore.getState().countSq).toEqual(1) - useStore.getState().dec() - expect(useStore.getState().count).toEqual(1) - expect(useStore.getState().countSq).toEqual(1) - expect(computeStateMock).toHaveBeenCalledTimes(1) - }) + expect(computeStateMock).toHaveBeenCalledTimes(1); + expect(useStore.getState().count).toEqual(1); + expect(useStore.getState().countSq).toEqual(1); + useStore.getState().inc(); + expect(useStore.getState().count).toEqual(2); + expect(useStore.getState().countSq).toEqual(1); + useStore.getState().dec(); + expect(useStore.getState().count).toEqual(1); + expect(useStore.getState().countSq).toEqual(1); + expect(computeStateMock).toHaveBeenCalledTimes(1); + }); test("disabling proxy causes compute to run every time", () => { - const useStore = makeStore({ disableProxy: true }) - expect(computeStateMock).toHaveBeenCalledTimes(1) - useStore.setState({ count: 4 }) - useStore.setState({ x: 2 }) - useStore.setState({ y: 3 }) - expect(useStore.getState().count).toEqual(4) - expect(useStore.getState().countSq).toEqual(16) - expect(computeStateMock).toHaveBeenCalledTimes(4) - }) -}) - -type CountSlice = Pick -type XYSlice = Pick + const useStore = makeStore({ disableProxy: true }); + expect(computeStateMock).toHaveBeenCalledTimes(1); + useStore.setState({ count: 4 }); + useStore.setState({ x: 2 }); + useStore.setState({ y: 3 }); + expect(useStore.getState().count).toEqual(4); + expect(useStore.getState().countSq).toEqual(16); + expect(computeStateMock).toHaveBeenCalledTimes(4); + }); +}); + +type CountSlice = Pick; +type XYSlice = Pick; function computeSlice(state: CountSlice): ComputedStore { const nestedResult = { stringified: JSON.stringify(state.count), - } + }; return { countSq: state.count ** 2, nestedResult, - } + }; } describe("slices pattern", () => { - const computeSliceMock = jest.fn(computeSlice) + const computeSliceMock = mock(computeSlice); const makeStore = () => { const createCountSlice: StateCreator< Store, @@ -160,40 +161,40 @@ describe("slices pattern", () => { dec: () => set((state) => ({ count: state.count - 1 })), }), computeSliceMock, - ) + ); const createXySlice: StateCreator = (set) => ({ x: 1, y: 1, // this should not trigger compute function inc: () => set((state) => ({ count: state.count + 2 })), - }) + }); return create()((...a) => ({ ...createCountSlice(...a), ...createXySlice(...a), - })) - } + })); + }; beforeEach(() => { - computeSliceMock.mockClear() - }) + computeSliceMock.mockClear(); + }); test("computed works on slices pattern example", () => { - const useStore = makeStore() - expect(computeSliceMock).toHaveBeenCalledTimes(1) - expect(useStore.getState().count).toEqual(1) - expect(useStore.getState().countSq).toEqual(1) - useStore.getState().inc() - expect(useStore.getState().count).toEqual(3) - expect(useStore.getState().countSq).toEqual(1) - expect(computeSliceMock).toHaveBeenCalledTimes(1) - useStore.getState().dec() - expect(useStore.getState().count).toEqual(2) - expect(useStore.getState().countSq).toEqual(4) - expect(computeSliceMock).toHaveBeenCalledTimes(2) - useStore.setState({ count: 4 }) - expect(useStore.getState().countSq).toEqual(16) - expect(computeSliceMock).toHaveBeenCalledTimes(3) - }) -}) + const useStore = makeStore(); + expect(computeSliceMock).toHaveBeenCalledTimes(1); + expect(useStore.getState().count).toEqual(1); + expect(useStore.getState().countSq).toEqual(1); + useStore.getState().inc(); + expect(useStore.getState().count).toEqual(3); + expect(useStore.getState().countSq).toEqual(1); + expect(computeSliceMock).toHaveBeenCalledTimes(1); + useStore.getState().dec(); + expect(useStore.getState().count).toEqual(2); + expect(useStore.getState().countSq).toEqual(4); + expect(computeSliceMock).toHaveBeenCalledTimes(2); + useStore.setState({ count: 4 }); + expect(useStore.getState().countSq).toEqual(16); + expect(computeSliceMock).toHaveBeenCalledTimes(3); + }); +}); From 38f9c3be920e01460702a2d49b02b56552d5ee5b Mon Sep 17 00:00:00 2001 From: Christian van der Loo Date: Wed, 21 Aug 2024 22:38:28 -0400 Subject: [PATCH 5/5] chore: reformat --- commitlint.config.mjs | 2 +- package.json | 16 +--- src/computed.test.ts | 210 +++++++++++++++++++++--------------------- 3 files changed, 108 insertions(+), 120 deletions(-) diff --git a/commitlint.config.mjs b/commitlint.config.mjs index fa584fb..fba73fb 100644 --- a/commitlint.config.mjs +++ b/commitlint.config.mjs @@ -1 +1 @@ -export default { extends: ["@commitlint/config-conventional"] }; +export default { extends: ["@commitlint/config-conventional"] } diff --git a/package.json b/package.json index b2dc9a3..e3d7563 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,8 @@ } }, "description": "A Zustand middleware to create computed states.", - "files": [ - "/dist" - ], - "keywords": [ - "zustand", - "computed", - "calculated", - "state", - "react", - "plugin", - "middleware", - "npm", - "typescript" - ], + "files": ["/dist"], + "keywords": ["zustand", "computed", "calculated", "state", "react", "plugin", "middleware", "npm", "typescript"], "license": "MIT", "scripts": { "check": "biome check --write", diff --git a/src/computed.test.ts b/src/computed.test.ts index cf274fe..5980562 100644 --- a/src/computed.test.ts +++ b/src/computed.test.ts @@ -1,35 +1,35 @@ -import { describe, expect, test, beforeEach, mock } from "bun:test"; -import { type StateCreator, create } from "zustand"; -import { type ComputedStateOpts, computed } from "./computed"; +import { describe, expect, test, beforeEach, mock } from "bun:test" +import { type StateCreator, create } from "zustand" +import { type ComputedStateOpts, computed } from "./computed" type Store = { - count: number; - x: number; - y: number; - inc: () => void; - dec: () => void; -}; + count: number + x: number + y: number + inc: () => void + dec: () => void +} type ComputedStore = { - countSq: number; + countSq: number nestedResult: { - stringified: string; - }; -}; + stringified: string + } +} function computeState(state: Store): ComputedStore { const nestedResult = { stringified: JSON.stringify(state.count), - }; + } return { countSq: state.count ** 2, nestedResult, - }; + } } describe("default config", () => { - const computeStateMock = mock(computeState); + const computeStateMock = mock(computeState) const makeStore = () => create( computed( @@ -42,52 +42,52 @@ describe("default config", () => { }), computeStateMock, ), - ); + ) - let useStore: ReturnType; + let useStore: ReturnType beforeEach(() => { - computeStateMock.mockClear(); - useStore = makeStore(); - }); + computeStateMock.mockClear() + useStore = makeStore() + }) test("computed works on simple counter example", () => { // note: this function should have been called once on store creation - expect(computeStateMock).toHaveBeenCalledTimes(1); - expect(useStore.getState().count).toEqual(1); - expect(useStore.getState().countSq).toEqual(1); - useStore.getState().inc(); - expect(useStore.getState().count).toEqual(2); - expect(useStore.getState().countSq).toEqual(4); - useStore.getState().dec(); - expect(useStore.getState().count).toEqual(1); - expect(useStore.getState().countSq).toEqual(1); - useStore.setState({ count: 4 }); - expect(useStore.getState().countSq).toEqual(16); - expect(computeStateMock).toHaveBeenCalledTimes(4); - }); + expect(computeStateMock).toHaveBeenCalledTimes(1) + expect(useStore.getState().count).toEqual(1) + expect(useStore.getState().countSq).toEqual(1) + useStore.getState().inc() + expect(useStore.getState().count).toEqual(2) + expect(useStore.getState().countSq).toEqual(4) + useStore.getState().dec() + expect(useStore.getState().count).toEqual(1) + expect(useStore.getState().countSq).toEqual(1) + useStore.setState({ count: 4 }) + expect(useStore.getState().countSq).toEqual(16) + expect(computeStateMock).toHaveBeenCalledTimes(4) + }) test("computed does not modify object ref even after change", () => { - useStore.setState({ count: 4 }); - expect(useStore.getState().count).toEqual(4); - const obj = useStore.getState().nestedResult; - useStore.setState({ count: 4 }); - const toCompare = useStore.getState().nestedResult; - expect(obj).toEqual(toCompare); - }); + useStore.setState({ count: 4 }) + expect(useStore.getState().count).toEqual(4) + const obj = useStore.getState().nestedResult + useStore.setState({ count: 4 }) + const toCompare = useStore.getState().nestedResult + expect(obj).toEqual(toCompare) + }) test("modifying variables x and y do not trigger compute function more than once, as they are not used in compute function", () => { - expect(computeStateMock).toHaveBeenCalledTimes(1); - useStore.setState({ x: 2 }); - expect(computeStateMock).toHaveBeenCalledTimes(2); - useStore.setState({ x: 3 }); - expect(computeStateMock).toHaveBeenCalledTimes(2); - useStore.setState({ y: 2 }); - expect(computeStateMock).toHaveBeenCalledTimes(2); - }); -}); + expect(computeStateMock).toHaveBeenCalledTimes(1) + useStore.setState({ x: 2 }) + expect(computeStateMock).toHaveBeenCalledTimes(2) + useStore.setState({ x: 3 }) + expect(computeStateMock).toHaveBeenCalledTimes(2) + useStore.setState({ y: 2 }) + expect(computeStateMock).toHaveBeenCalledTimes(2) + }) +}) describe("custom config", () => { - const computeStateMock = mock(computeState); + const computeStateMock = mock(computeState) const makeStore = (opts?: ComputedStateOpts) => create( computed( @@ -101,54 +101,54 @@ describe("custom config", () => { computeStateMock, opts, ), - ); + ) beforeEach(() => { - computeStateMock.mockClear(); - }); + computeStateMock.mockClear() + }) test("computed does not update when a custom key selector is given", () => { - const useStore = makeStore({ keys: ["x", "y"] }); + const useStore = makeStore({ keys: ["x", "y"] }) // because we only care about x and y, the compute function should not be called when count changes - expect(computeStateMock).toHaveBeenCalledTimes(1); - expect(useStore.getState().count).toEqual(1); - expect(useStore.getState().countSq).toEqual(1); - useStore.getState().inc(); - expect(useStore.getState().count).toEqual(2); - expect(useStore.getState().countSq).toEqual(1); - useStore.getState().dec(); - expect(useStore.getState().count).toEqual(1); - expect(useStore.getState().countSq).toEqual(1); - expect(computeStateMock).toHaveBeenCalledTimes(1); - }); + expect(computeStateMock).toHaveBeenCalledTimes(1) + expect(useStore.getState().count).toEqual(1) + expect(useStore.getState().countSq).toEqual(1) + useStore.getState().inc() + expect(useStore.getState().count).toEqual(2) + expect(useStore.getState().countSq).toEqual(1) + useStore.getState().dec() + expect(useStore.getState().count).toEqual(1) + expect(useStore.getState().countSq).toEqual(1) + expect(computeStateMock).toHaveBeenCalledTimes(1) + }) test("disabling proxy causes compute to run every time", () => { - const useStore = makeStore({ disableProxy: true }); - expect(computeStateMock).toHaveBeenCalledTimes(1); - useStore.setState({ count: 4 }); - useStore.setState({ x: 2 }); - useStore.setState({ y: 3 }); - expect(useStore.getState().count).toEqual(4); - expect(useStore.getState().countSq).toEqual(16); - expect(computeStateMock).toHaveBeenCalledTimes(4); - }); -}); - -type CountSlice = Pick; -type XYSlice = Pick; + const useStore = makeStore({ disableProxy: true }) + expect(computeStateMock).toHaveBeenCalledTimes(1) + useStore.setState({ count: 4 }) + useStore.setState({ x: 2 }) + useStore.setState({ y: 3 }) + expect(useStore.getState().count).toEqual(4) + expect(useStore.getState().countSq).toEqual(16) + expect(computeStateMock).toHaveBeenCalledTimes(4) + }) +}) + +type CountSlice = Pick +type XYSlice = Pick function computeSlice(state: CountSlice): ComputedStore { const nestedResult = { stringified: JSON.stringify(state.count), - }; + } return { countSq: state.count ** 2, nestedResult, - }; + } } describe("slices pattern", () => { - const computeSliceMock = mock(computeSlice); + const computeSliceMock = mock(computeSlice) const makeStore = () => { const createCountSlice: StateCreator< Store, @@ -161,40 +161,40 @@ describe("slices pattern", () => { dec: () => set((state) => ({ count: state.count - 1 })), }), computeSliceMock, - ); + ) const createXySlice: StateCreator = (set) => ({ x: 1, y: 1, // this should not trigger compute function inc: () => set((state) => ({ count: state.count + 2 })), - }); + }) return create()((...a) => ({ ...createCountSlice(...a), ...createXySlice(...a), - })); - }; + })) + } beforeEach(() => { - computeSliceMock.mockClear(); - }); + computeSliceMock.mockClear() + }) test("computed works on slices pattern example", () => { - const useStore = makeStore(); - expect(computeSliceMock).toHaveBeenCalledTimes(1); - expect(useStore.getState().count).toEqual(1); - expect(useStore.getState().countSq).toEqual(1); - useStore.getState().inc(); - expect(useStore.getState().count).toEqual(3); - expect(useStore.getState().countSq).toEqual(1); - expect(computeSliceMock).toHaveBeenCalledTimes(1); - useStore.getState().dec(); - expect(useStore.getState().count).toEqual(2); - expect(useStore.getState().countSq).toEqual(4); - expect(computeSliceMock).toHaveBeenCalledTimes(2); - useStore.setState({ count: 4 }); - expect(useStore.getState().countSq).toEqual(16); - expect(computeSliceMock).toHaveBeenCalledTimes(3); - }); -}); + const useStore = makeStore() + expect(computeSliceMock).toHaveBeenCalledTimes(1) + expect(useStore.getState().count).toEqual(1) + expect(useStore.getState().countSq).toEqual(1) + useStore.getState().inc() + expect(useStore.getState().count).toEqual(3) + expect(useStore.getState().countSq).toEqual(1) + expect(computeSliceMock).toHaveBeenCalledTimes(1) + useStore.getState().dec() + expect(useStore.getState().count).toEqual(2) + expect(useStore.getState().countSq).toEqual(4) + expect(computeSliceMock).toHaveBeenCalledTimes(2) + useStore.setState({ count: 4 }) + expect(useStore.getState().countSq).toEqual(16) + expect(computeSliceMock).toHaveBeenCalledTimes(3) + }) +})