]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
test: test warn mapStores
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 3 May 2021 09:21:17 +0000 (11:21 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 3 May 2021 09:21:17 +0000 (11:21 +0200)
__tests__/mapHelpers.spec.ts

index e86df276132ce5b2b9ee2879fcf301e42114665f..f8ec2a0c07c1c8b544b6ac74fe37d3b0631c0d93 100644 (file)
@@ -14,6 +14,7 @@ import VueCompositionAPI, {
   nextTick,
   defineComponent,
 } from '@vue/composition-api'
+import { mockWarn } from 'jest-mock-warn'
 
 describe('Map Helpers', () => {
   const useCartStore = defineStore({ id: 'cart' })
@@ -43,6 +44,7 @@ describe('Map Helpers', () => {
   localVue.use(PiniaPlugin)
 
   describe('mapStores', () => {
+    mockWarn()
     it('mapStores computes only once when mapping one store', async () => {
       const pinia = createPinia()
       const fromStore = jest.fn(function () {
@@ -128,6 +130,11 @@ describe('Map Helpers', () => {
       await wrapper.trigger('click')
       expect(wrapper.text()).toBe('2')
     })
+
+    it('should warn when an array is passed', () => {
+      mapStores([])
+      expect('pass all stores to "mapStores()"').toHaveBeenWarned()
+    })
   })
 
   it('mapGetters', () => {