Large Application Patterns with Vuex Chapter 18
getters: {
euro: state => state.bitcoin * state.rate,
houses: (state, getters) => getters.euro() / 150000
})
Passing an argument
If a getter returns a function with an argument, that argument will be the argument of the
getter:
getters: {
getWorldWonder: state => nth => state.worldWonders[nth]
}
In our recipe, a practical example could specify the average cost of a house in the getter
from the previous paragraph:
const store = new Vuex.Store({
state: {
bitcoin: 600,
rate: 1000
},
getters: {
euro: state => state.bitcoin * state.rate,
houses: (state, getters) => averageHousePrice => {
return getters.euro() / averageHousePrice
}
})
Testing your store
In this recipe, you will write tests for a Vuex store.
Getting ready
This recipe requires knowledge of Unit testing and End-To-End testing and little familiarity
with Vuex.