]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: add todo test
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 31 May 2022 09:10:36 +0000 (11:10 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 31 May 2022 09:10:41 +0000 (11:10 +0200)
packages/pinia/__tests__/state.spec.ts

index a09a42a9c95a74bc73e819f7cef533bfaa7d95a2..4fa2d26bdc18684625b2e0c1ab1af472c3a0af1d 100644 (file)
@@ -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)
+    })
   })
 })