Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Large Application Patterns with Vuex Chapter 18

})

})

}

}

}).default
}

This will ensure that any call to the get method of axios will always return a new to-do


item.


Then, we want to ensure that the ADD_ITEMS mutation is called upon dispatch:


describe('actions', () => {
const actionsInjector =
require('inject-loader!@/store/actions')
const buyHouseTodo = {
id: 84,
text: 'Buy house',
done: true
}
const actions = actionsInjector({
'axios': {
get () {
return new Promise(resolve => {
resolve({ data: [buyHouseTodo] })
})
}
}
}).default
it(`downloadNew should commit ADD_ITEMS
with the 'Buy house' todo when successful`, done => {
const commit = (type, payload) => {
try {
expect(type).to.equal('ADD_ITEMS')
expect(payload).to.deep.equal([buyHouseTodo])
done()
} catch (error) {
done(error)
}
}
actions.downloadNew({ commit })
})
})
Free download pdf