2019-10-04 18:06:01 +00:00
|
|
|
import Vuex from 'vuex'
|
2020-09-18 22:46:37 +00:00
|
|
|
import { mount, createLocalVue, config, RouterLinkStub } from '@vue/test-utils'
|
2019-10-04 18:06:01 +00:00
|
|
|
import flushPromises from 'flush-promises'
|
|
|
|
import Element from 'element-ui'
|
|
|
|
import UsersShow from '@/views/users/show'
|
2020-08-28 21:43:57 +00:00
|
|
|
import { storeConfig } from './store.conf'
|
2019-10-04 18:06:01 +00:00
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
|
|
|
|
config.mocks["$t"] = () => {}
|
2020-09-18 22:46:37 +00:00
|
|
|
config.stubs.transition = false
|
2019-10-04 18:06:01 +00:00
|
|
|
|
|
|
|
const localVue = createLocalVue()
|
|
|
|
localVue.use(Vuex)
|
|
|
|
localVue.use(Element)
|
|
|
|
|
|
|
|
const $route = {
|
|
|
|
params: {
|
|
|
|
id: '2'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-09 11:02:53 +00:00
|
|
|
jest.mock('@/api/app')
|
2019-10-04 18:06:01 +00:00
|
|
|
jest.mock('@/api/nodeInfo')
|
|
|
|
jest.mock('@/api/users')
|
2020-10-12 20:39:12 +00:00
|
|
|
jest.mock('@/api/settings')
|
2019-10-04 18:06:01 +00:00
|
|
|
|
2020-05-24 18:14:58 +00:00
|
|
|
describe('User profile', () => {
|
2019-10-04 18:06:01 +00:00
|
|
|
let store
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
store = new Vuex.Store(cloneDeep(storeConfig))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('fetches user profile', async (done) => {
|
|
|
|
const wrapper = mount(UsersShow, {
|
|
|
|
store,
|
|
|
|
localVue,
|
|
|
|
sync: false,
|
2020-09-18 22:46:37 +00:00
|
|
|
stubs: {
|
|
|
|
RouterLink: RouterLinkStub
|
|
|
|
},
|
2019-10-04 18:06:01 +00:00
|
|
|
mocks: {
|
|
|
|
$route
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.user-profile-card').isVisible()).toBe(true)
|
|
|
|
expect(store.state.userProfile.user.nickname).toBe('allis')
|
|
|
|
expect(store.state.userProfile.user.roles.admin).toBe(true)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|