From 2dda5a5ad1c405468568f9ca92afc1bd1f628e70 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 31 May 2022 11:10:36 +0200 Subject: [PATCH] test: add todo test --- packages/pinia/__tests__/state.spec.ts | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/pinia/__tests__/state.spec.ts b/packages/pinia/__tests__/state.spec.ts index a09a42a9..4fa2d26b 100644 --- a/packages/pinia/__tests__/state.spec.ts +++ b/packages/pinia/__tests__/state.spec.ts @@ -362,5 +362,33 @@ describe('State', () => { expect(main.myCustom).toBe(1) expect(spy).toHaveBeenCalledTimes(4) }) + + // TODO: should warn of nested skipHydrate() calls + it.todo('hydrates custom nested refs setup', async () => { + const pinia = createPinia() + pinia.state.value.main = { a: { myCustom: 24 } } + + setActivePinia(pinia) + + const useMainOptions = defineStore('main', () => ({ + a: ref({ + myCustom: skipHydrate(useCustomRef()), + }), + })) + + const main = useMainOptions() + + // 0 because it skipped hydration + expect(main.a.myCustom).toBe(0) + expect(spy).toHaveBeenCalledTimes(0) + main.a.myCustom++ + main.$state.a.myCustom++ + main.$patch({ a: { myCustom: 0 } }) + main.$patch((state) => { + state.a.myCustom++ + }) + expect(main.a.myCustom).toBe(1) + expect(spy).toHaveBeenCalledTimes(4) + }) }) }) -- 2.47.2