Add test for running on mounted actions in Statuses

This commit is contained in:
Angelina Filippova 2020-05-11 21:20:52 +03:00
parent 744872d64a
commit 6ec7d89a91
4 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,4 @@
export async function fetchPeers(authHost, token) {
const data = ['lain.com', 'heaven.com']
return Promise.resolve({ data })
}

View file

@ -5,3 +5,11 @@ export async function changeStatusScope(id, sensitive, visibility, authHost, tok
export async function deleteStatus(id, authHost, token) {
return Promise.resolve()
}
export async function fetchStatusesCount(instance, authHost, token) {
const data = {
'status_visibility':
{ 'direct': 4, 'private': 10, 'public': 4, 'unlisted': 10 }
}
return Promise.resolve({ data })
}

View file

@ -0,0 +1,41 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import Element from 'element-ui'
import Statuses from '@/views/statuses/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/app')
jest.mock('@/api/status')
jest.mock('@/api/peers')
jest.mock('@/api/nodeInfo')
describe('Statuses', () => {
let store
beforeEach(() => {
store = new Vuex.Store(cloneDeep(storeConfig))
})
it('fetches peers and statuses count', async (done) => {
mount(Statuses, {
store,
localVue
})
await flushPromises()
const statusVisibilityCount = store.state.status.statusVisibility
expect(statusVisibilityCount.direct).toEqual(4)
expect(statusVisibilityCount.private).toEqual(10)
expect(statusVisibilityCount.public).toEqual(4)
expect(statusVisibilityCount.unlisted).toEqual(10)
done()
})
})

View file

@ -0,0 +1,17 @@
import app from '@/store/modules/app'
import peers from '@/store/modules/peers'
import user from '@/store/modules/user'
import settings from '@/store/modules/settings'
import status from '@/store/modules/status'
import getters from '@/store/getters'
export default {
modules: {
app,
peers,
settings,
status,
user
},
getters
}