forked from AkkomaGang/admin-fe
91 lines
2.4 KiB
JavaScript
91 lines
2.4 KiB
JavaScript
import Vuex from 'vuex'
|
|
import { mount, createLocalVue, config } from '@vue/test-utils'
|
|
import flushPromises from 'flush-promises'
|
|
import Element from 'element-ui'
|
|
import StatusShow from '@/views/statuses/show'
|
|
import storeConfig from './statusShowStore.conf'
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
config.mocks["$t"] = () => {}
|
|
|
|
const localVue = createLocalVue()
|
|
localVue.use(Vuex)
|
|
localVue.use(Element)
|
|
|
|
const $route = {
|
|
params: {
|
|
id: '9vJOO3iFPyjNaEhJ5s'
|
|
}
|
|
}
|
|
|
|
jest.mock('@/api/app')
|
|
jest.mock('@/api/status')
|
|
jest.mock('@/api/peers')
|
|
jest.mock('@/api/nodeInfo')
|
|
jest.mock('@/api/users')
|
|
|
|
describe('Status show page', () => {
|
|
let store
|
|
|
|
beforeEach(() => {
|
|
store = new Vuex.Store(cloneDeep(storeConfig))
|
|
})
|
|
|
|
it(`fetches single status and user's statuses`, async (done) => {
|
|
const wrapper = mount(StatusShow, {
|
|
store,
|
|
localVue,
|
|
sync: false,
|
|
stubs: ['router-link'],
|
|
mocks: {
|
|
$route
|
|
}
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.status-container').isVisible()).toBe(true)
|
|
expect(store.state.status.fetchedStatus.id).toBe('9vJOO3iFPyjNaEhJ5s')
|
|
expect(store.state.status.fetchedStatus.account.display_name).toBe('dolin')
|
|
expect(store.state.userProfile.statuses.length).toEqual(3)
|
|
done()
|
|
})
|
|
|
|
it(`renders links and user's moderation menu`, async (done) => {
|
|
const wrapper = mount(StatusShow, {
|
|
store,
|
|
localVue,
|
|
sync: false,
|
|
stubs: ['router-link'],
|
|
mocks: {
|
|
$route
|
|
}
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('router-link-stub h1').text()).toBe('dolin')
|
|
expect(wrapper.find('button.moderate-user-button').exists()).toBe(true)
|
|
expect(wrapper.find('.el-dropdown-menu').exists()).toBe(true)
|
|
done()
|
|
})
|
|
|
|
it(`renders status card`, async (done) => {
|
|
const wrapper = mount(StatusShow, {
|
|
store,
|
|
localVue,
|
|
sync: false,
|
|
stubs: ['router-link'],
|
|
mocks: {
|
|
$route
|
|
}
|
|
})
|
|
await flushPromises()
|
|
|
|
expect(wrapper.find('.status-card').exists()).toBe(true)
|
|
expect(wrapper.find('router-link-stub h3').text()).toBe('dolin')
|
|
expect(wrapper.find('span.el-tag').text()).not.toBe('Sensitive')
|
|
expect(wrapper.find('span.el-tag').text()).toBe('Public')
|
|
expect(wrapper.find('button.status-actions-button').exists()).toBe(true)
|
|
expect(wrapper.find('.status-body .status-content').text()).toBe('pizza makes everything better')
|
|
done()
|
|
})
|
|
})
|