]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: unify naming of store (#2190)
authorJulian S <Theiaz@users.noreply.github.com>
Wed, 10 May 2023 07:36:55 +0000 (09:36 +0200)
committerGitHub <noreply@github.com>
Wed, 10 May 2023 07:36:55 +0000 (09:36 +0200)
packages/docs/cookbook/testing.md

index dc1d86541f467e2fe1c97b3348f2601376b4d1bd..2df962b954077cbd1ffc62df458aaf7fca11f604 100644 (file)
@@ -26,7 +26,7 @@ To unit test a store, the most important part is creating a `pinia` instance:
 ```js
 // stores/counter.spec.ts
 import { setActivePinia, createPinia } from 'pinia'
-import { useCounter } from '../src/stores/counter'
+import { useCounterStore } from '../src/stores/counter'
 
 describe('Counter Store', () => {
   beforeEach(() => {
@@ -37,14 +37,14 @@ describe('Counter Store', () => {
   })
 
   it('increments', () => {
-    const counter = useCounter()
+    const counter = useCounterStore()
     expect(counter.n).toBe(0)
     counter.increment()
     expect(counter.n).toBe(1)
   })
 
   it('increments by amount', () => {
-    const counter = useCounter()
+    const counter = useCounterStore()
     counter.increment(10)
     expect(counter.n).toBe(10)
   })
@@ -188,7 +188,7 @@ By default, any getter will be computed like regular usage but you can manually
 import { defineStore } from 'pinia'
 import { createTestingPinia } from '@pinia/testing'
 
-const useCounter = defineStore('counter', {
+const useCounterStore = defineStore('counter', {
   state: () => ({ n: 1 }),
   getters: {
     double: (state) => state.n * 2,
@@ -196,7 +196,7 @@ const useCounter = defineStore('counter', {
 })
 
 const pinia = createTestingPinia()
-const counter = useCounter(pinia)
+const counter = useCounterStore(pinia)
 
 counter.double = 3 // ðŸª„ getters are writable only in tests