Add test to fetching reports

This commit is contained in:
Angelina Filippova 2019-04-03 18:29:33 +03:00
parent bca639f79f
commit 6442705737
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,34 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import Element from 'element-ui'
import Reports from '@/views/reports/index'
import storeConfig from './store.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Element)
// jest.mock('@/api/reports')
describe('Reports', () => {
let store
beforeEach(() => {
store = new Vuex.Store(cloneDeep(storeConfig))
})
it('initially fetches reports', async (done) => {
const wrapper = mount(Reports, {
store,
localVue
})
await wrapper.vm.$nextTick()
const initialReports = store.state.reports.fetchedReports.length
expect(initialReports).toEqual(3)
done()
})
})

View file

@ -0,0 +1,15 @@
import app from '@/store/modules/app'
import user from '@/store/modules/user'
import users from '@/store/modules/users'
import reports from '@/store/modules/reports'
import getters from '@/store/getters'
export default {
modules: {
app,
user,
users,
reports
},
getters
}