我正在尝试在async data
钩接到vuejs组件期间检查是否已调度一些存储操作。
这是我的异步数据内容:
async asyncData ({ store }) {
const homePageContent = store.dispatch('info/fetchHomePageContent')
const auctionsPromise = store.dispatch('auction/fetchAuctionProductsList', { page: 1, limit: 10 })
const auctionsMetaPromise = store.dispatch('auction/fetchAuctionProductsListMeta', { page: 1, limit: 10 })
await homePageContent
await auctionsPromise
await auctionsMetaPromise
}
这是我在测试中挂载的模拟商店:
export const infoStoreMock = {
modules: {
info: {
namespaced: true,
actions: {
fetchHomePageContent () {
console.log('it works!')
}
}
}
}
}
这是我的单元测试的一部分,使用vue-test-utils和ava测试运行程序:
test.beforeEach(() => {
localVue = createLocalVue()
localVue.use(Vuex)
store = new Vuex.Store(infoStoreMock)
wrapper = shallowMount(HomepagePage, {
localVue,
store
})
})
test('should call store actions at the async data hook', t => {
const spy = sinon.spy(infoStoreMock.modules.info.actions, 'fetchHomePageContent')
t.truthy(spy.called)
})
我进行测试时,根本没有召唤间谍。
我想念什么?
提前谢谢