]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: refactor tests
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 17 May 2021 09:10:51 +0000 (11:10 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 17 May 2021 09:10:51 +0000 (11:10 +0200)
docs/.vitepress/components/TestCounterStore.vue [new file with mode: 0644]
docs/.vitepress/components/TestStore.vue
docs/.vitepress/components/ThemeToggle.vue
docs/.vitepress/theme/index.js
docs/index.md

diff --git a/docs/.vitepress/components/TestCounterStore.vue b/docs/.vitepress/components/TestCounterStore.vue
new file mode 100644 (file)
index 0000000..d0cfa65
--- /dev/null
@@ -0,0 +1,26 @@
+<template>
+  <p>Counter :{{ counterStore.n }}</p>
+
+  <button @click="counterStore.increment">Increment</button>
+  <button @click="counterStore.n++">Direct Increment</button>
+  <button
+    @click="
+      counterStore.$patch((state) => {
+        state.n++
+        state.incrementedTimes++
+      })
+    "
+  >
+    Direct patch
+  </button>
+  <button @click="counterStore.fail">Fail</button>
+  <button @click="counterStore.decrementToZero(300, true)">To ZERO</button>
+</template>
+
+<script setup>
+import { useCartStore } from '../stores/cart'
+import { useCounter } from '../stores/counter'
+
+const counterStore = useCounter()
+const cartStore = useCartStore()
+</script>
index 4f752ba373504b77cd02deed99c45b2551da8942..2a624eea4e503cfa5bb7a2aa83b29300a767d874 100644 (file)
@@ -1,7 +1,14 @@
-<template>I have a store "{{ userStore.name }}"</template>
+<template>
+  <p>
+    I have a store "{{ userStore.name }}". I have
+    {{ cartStore.items.length }} items in the cart.
+  </p>
+</template>
 
 <script setup lang="ts">
 import { useUserStore } from '../stores/user'
+import { useCartStore } from '../stores/cart'
 
 const userStore = useUserStore()
+const cartStore = useCartStore()
 </script>
index 02d59cff9d1e77db4a3b912439962cc93d88410e..a8e85466e170cd6553ea0f0072308ebea837a546 100644 (file)
       <path d="M15 2.005h2v5h-2z" fill="currentColor"></path>
     </svg>
   </button>
-
-  <p>Counter :{{ counterStore.n }}</p>
-
-  <button @click="counterStore.increment">Increment</button>
-  <button @click="counterStore.n++">Direct Increment</button>
-  <button
-    @click="
-      counterStore.$patch((state) => {
-        state.n++
-        state.incrementedTimes++
-      })
-    "
-  >
-    Direct patch
-  </button>
-  <button @click="counterStore.fail">Fail</button>
-  <button @click="counterStore.decrementToZero(300, true)">To ZERO</button>
 </template>
 
 <script setup lang="ts">
 import { computed, onMounted, ref, watchEffect } from 'vue'
-import { useCartStore } from '../stores/cart'
-import { useCounter } from '../stores/counter'
 
 const isBrowser = typeof window !== 'undefined'
 
@@ -91,9 +72,6 @@ function isDarkMode() {
   return !window.matchMedia(PREFERS_LIGHT).matches
 }
 
-const counterStore = useCounter()
-const cartStore = useCartStore()
-
 const storageKey = 'pinia-color-scheme'
 
 const localIsDark = ref(isDarkMode())
index 6e181319042e6cc811ecf35530e84506bcc7dff3..d7d54012907b9550352ecb7122d7d93743cc7185 100644 (file)
@@ -1,7 +1,7 @@
 import Theme from 'vitepress/theme'
 import './custom.css'
 import './code-theme.css'
-import { createPinia } from '../../../src'
+// import { createPinia } from '../../../src'
 
 const { Layout } = Theme
 
@@ -23,7 +23,7 @@ Layout.mounted = function () {
 const config = {
   ...Theme,
   enhanceApp({ app }) {
-    app.use(createPinia())
+    // app.use(createPinia())
   },
 }
 
index 13ac662d98e34df71c209d3a3d9cd6340901d784..cd66c6a304debd8d628df9287775c5fc6137001a 100644 (file)
@@ -24,12 +24,12 @@ footer: MIT Licensed | Copyright © 2019-present Eduardo San Martin Morote
 ---
 
 <ThemeToggle/>
-<TestStore/>
+<!-- <TestStore/> -->
 
 <HomeSponsors />
 
 <script setup>
 import HomeSponsors from './.vitepress/components/HomeSponsors.vue'
 import ThemeToggle from './.vitepress/components/ThemeToggle.vue'
-import TestStore from './.vitepress/components/TestStore.vue'
+// import TestStore from './.vitepress/components/TestStore.vue'
 </script>