Created
April 6, 2019 08:26
-
-
Save lusarz/5a4c736840316ad1b268978fcbdfd3f7 to your computer and use it in GitHub Desktop.
Build vuex store in unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount } from '@vue/test-utils'; | |
import Vuex from 'vuex'; | |
import Form from 'components/form'; | |
export function buildStores (stores) { | |
const modules = {}; | |
stores.forEach(config => { | |
modules[config.name] = { | |
namespaced: true, | |
state: config.state || {}, | |
getters: config.getters || {}, | |
actions: config.actions || {}, | |
mutations: config.mutations || {} | |
}; | |
}); | |
return new Vuex.Store({ modules }); | |
} | |
// Potem w testach | |
const wrapper = shallowMount(Form, { | |
store: buildStores([{ | |
name: 'subscriptions', | |
getters: { | |
subscriber: () => ({ name: 'xyz', saml: {} }), | |
termsAccepted: () => true | |
} | |
}]) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment