]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: refactor property name to avoid collisions
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 12 May 2021 09:27:55 +0000 (11:27 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 13 May 2021 11:06:57 +0000 (13:06 +0200)
__tests__/storePlugins.spec.ts

index 91785256211d4b74266636b57a3cf0c70ae4d565..36c7cfac35c565dedd64920e2053a95766a6f52c 100644 (file)
@@ -4,7 +4,7 @@ import Vue from 'vue'
 
 declare module '../src' {
   export interface PiniaCustomProperties<Id> {
-    n: number
+    pluginN: number
     // uid: App['_uid']
     hasPinia: boolean
     idFromPlugin: Id
@@ -17,14 +17,12 @@ describe('store plugins', () => {
 
     actions: {
       incrementN() {
-        return this.n++
+        return this.pluginN++
       },
     },
 
     getters: {
-      doubleN(): number {
-        return this.n * 2
-      },
+      doubleN: (state) => state.pluginN * 2,
     },
   })
   const localVue = createLocalVue()
@@ -37,14 +35,14 @@ describe('store plugins', () => {
 
     // must call use after installing the plugin
     pinia.use(() => {
-      return { n: 20 }
+      return { pluginN: 20 }
     })
 
     const store = useStore()
 
-    expect(store.n).toBe(20)
+    expect(store.pluginN).toBe(20)
     // @ts-expect-error: n is a number
-    store.n.notExisting
+    store.pluginN.notExisting
     // @ts-expect-error: it should always be 'test'
     store.idFromPlugin == 'hello'
   })
@@ -53,7 +51,7 @@ describe('store plugins', () => {
     const pinia = createPinia()
     pinia.Vue = Vue
 
-    pinia.use(() => ({ n: 1 }))
+    pinia.use(() => ({ pluginN: 1 }))
     pinia.use((pinia) => ({ hasPinia: !!pinia }))
 
     mount({ template: '<p/>' }, { localVue, pinia })
@@ -62,7 +60,7 @@ describe('store plugins', () => {
 
     const store = useStore()
 
-    expect(store.n).toBe(1)
+    expect(store.pluginN).toBe(1)
     expect(store.hasPinia).toBe(true)
   })
 
@@ -73,7 +71,7 @@ describe('store plugins', () => {
 
     // must call use after installing the plugin
     pinia.use(() => {
-      return { n: 20 }
+      return { pluginN: 20 }
     })
 
     const store = useStore()
@@ -88,7 +86,7 @@ describe('store plugins', () => {
 
     // must call use after installing the plugin
     pinia.use(() => {
-      return { n: 20 }
+      return { pluginN: 20 }
     })
 
     const store = useStore()