admin-fe/test/views/reports/index.test.js

41 lines
1,004 B
JavaScript
Raw Permalink Normal View History

2019-04-03 15:29:33 +00:00
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'
import flushPromises from 'flush-promises'
2019-04-03 15:29:33 +00:00
config.mocks["$t"] = () => {}
2020-09-18 22:46:37 +00:00
config.stubs['reports-filter'] = { template: '<div />'}
config.stubs['timeline-item'] = { template: '<div />'}
2019-04-03 15:29:33 +00:00
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Element)
2020-04-17 22:27:00 +00:00
jest.mock('@/api/app')
jest.mock('@/api/nodeInfo')
jest.mock('@/api/reports')
2020-10-02 21:04:01 +00:00
jest.mock('@/api/settings')
2019-04-03 15:29:33 +00:00
describe('Reports', () => {
let store
beforeEach(() => {
store = new Vuex.Store(cloneDeep(storeConfig))
})
it('initially fetches reports', async (done) => {
const wrapper = mount(Reports, {
store,
localVue
})
await flushPromises()
2019-04-03 15:29:33 +00:00
const initialReports = store.state.reports.fetchedReports.length
expect(initialReports).toEqual(7)
done()
})
2019-04-03 15:29:33 +00:00
})