From: Julian S Date: Wed, 10 May 2023 07:36:55 +0000 (+0200) Subject: docs: unify naming of store (#2190) X-Git-Tag: @pinia/nuxt@0.4.11~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=804e6d585949cf3b341fdd7f0e07a2991ef1b09b;p=thirdparty%2Fvuejs%2Fpinia.git docs: unify naming of store (#2190) --- diff --git a/packages/docs/cookbook/testing.md b/packages/docs/cookbook/testing.md index dc1d8654..2df962b9 100644 --- a/packages/docs/cookbook/testing.md +++ b/packages/docs/cookbook/testing.md @@ -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