forked from AkkomaGang/admin-fe
Add test to fetching reports
This commit is contained in:
parent
bca639f79f
commit
6442705737
2 changed files with 49 additions and 0 deletions
34
test/views/reports/index.test.js
Normal file
34
test/views/reports/index.test.js
Normal 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()
|
||||
})
|
||||
})
|
15
test/views/reports/store.conf.js
Normal file
15
test/views/reports/store.conf.js
Normal 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
|
||||
}
|
Loading…
Reference in a new issue