]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: refactor not implemented
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 23 Jun 2020 08:14:40 +0000 (10:14 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 22 Sep 2020 07:55:49 +0000 (09:55 +0200)
__tests__/pinia/stores/combined.ts
src/ssrPlugin.ts

index 924ba95972f9b09d82bdfb4bb93a5063ba37fd71..e9457b0088844a99bdfc52c715edbb3f0b34b965 100644 (file)
@@ -1,15 +1,32 @@
 import { useUserStore } from './user'
 import { useCartStore } from './cart'
-import { pinia, CombinedState } from '../../../src/pinia'
+import { pinia } from '../../../src'
 // in this file we could import other stores that use one each other while
 // avoiding any recursive import
 
-type S = CombinedState<{
-  user: typeof useUserStore
-  cart: typeof useCartStore
-}>
+// TODO: not implemented
 
-let a: S
+const useCartUserStore = pinia(
+  { user: useUserStore, cart: useCartStore },
+  {
+    getters: {
+      combinedGetter: ({ user, cart }) =>
+        `Hi ${user.state.name}, you have ${cart.state.list.length} items in your cart. It costs ${cart.price}.`,
+    },
+    actions: {
+      async orderCart() {
+        try {
+          await apiOrderCart(this.user.state.token, this.cart.state.items)
+          this.cart.emptyCart()
+        } catch (err) {
+          displayError(err)
+        }
+      },
+    },
+  }
+)
+
+const a = useCartUserStore()
 
 a.user.isAdmin = false
 a.cart.rawItems.push()
index b45c0cc188c3a29c44720d0d3f6c2ad522eb2d8d..7962caad2df9ad4e5cee6328325212529d709a27 100644 (file)
@@ -28,7 +28,7 @@ export const PiniaSsr = (vue: VueConstructor) => {
       if (serverPrefetch) {
         const patchedServerPrefetch = Array.isArray(serverPrefetch)
           ? serverPrefetch.slice()
-          : // serverPrefetch not being an array cannot be triggered due tue options merge
+          : // serverPrefetch not being an array cannot be triggered due to options merge
             // https://github.com/vuejs/vue/blob/7912f75c5eb09e0aef3e4bfd8a3bb78cad7540d7/src/core/util/options.js#L149
             /* istanbul ignore next */
             [serverPrefetch]