Fix test after vue-test-utils update

This commit is contained in:
Angelina Filippova 2020-09-19 01:46:37 +03:00
parent 3ac082b4ab
commit bc812751af
8 changed files with 89 additions and 34 deletions

View file

@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import { mount, createLocalVue, config, RouterLinkStub } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import Element from 'element-ui'
import Invites from '@/views/invites/index'
@ -28,7 +28,9 @@ describe('Invite tokens', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -42,7 +44,9 @@ describe('Invite tokens', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -66,7 +70,9 @@ describe('Invite tokens', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
expect(store.state.invites.inviteTokens.length).toEqual(3)
@ -101,7 +107,9 @@ describe('Invite tokens', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -120,7 +128,9 @@ describe('Invite tokens', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
const dialog = wrapper.find('div.el-dialog__wrapper .invite-via-email-dialog')

View file

@ -7,8 +7,8 @@ import { cloneDeep } from 'lodash'
import flushPromises from 'flush-promises'
config.mocks["$t"] = () => {}
config.stubs['reports-filter'] = '<div />'
config.stubs['timeline-item'] = '<div />'
config.stubs['reports-filter'] = { template: '<div />'}
config.stubs['timeline-item'] = { template: '<div />'}
const localVue = createLocalVue()
localVue.use(Vuex)

View file

@ -5,6 +5,7 @@ import Settings from '@/views/settings/index'
import flushPromises from 'flush-promises'
import app from '@/store/modules/app'
import settings from '@/store/modules/settings'
import user from '@/store/modules/user'
import getters from '@/store/getters'
config.mocks["$t"] = () => {}
@ -24,7 +25,8 @@ describe('Settings search', () => {
store = new Vuex.Store({
modules: {
app: { ...app, actions: appActions },
settings: { ...settings, actions }
settings: { ...settings, actions },
user: { ...user, state: { ...user.state, authHost: 'localhost:4000' }}
},
getters
})

View file

@ -7,6 +7,7 @@ import storeConfig from './store.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
config.stubs.transition = false
const localVue = createLocalVue()
localVue.use(Vuex)

View file

@ -7,6 +7,7 @@ import storeConfig from './storeForPagination.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
config.stubs.transition = false
const localVue = createLocalVue()
localVue.use(Vuex)

View file

@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import { mount, createLocalVue, config, RouterLinkStub } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import Element from 'element-ui'
import StatusShow from '@/views/statuses/show'
@ -7,6 +7,7 @@ import storeConfig from './statusShowStore.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
config.stubs.transition = false
const localVue = createLocalVue()
localVue.use(Vuex)
@ -36,7 +37,9 @@ describe('Status show page', () => {
store,
localVue,
sync: false,
stubs: ['router-link'],
stubs: {
RouterLink: RouterLinkStub
},
mocks: {
$route
}
@ -55,14 +58,16 @@ describe('Status show page', () => {
store,
localVue,
sync: false,
stubs: ['router-link'],
stubs: {
RouterLink: RouterLinkStub
},
mocks: {
$route
}
})
await flushPromises()
expect(wrapper.find('router-link-stub h1').text()).toBe('dolin')
expect(wrapper.findComponent(RouterLinkStub).find('h1').text()).toBe('dolin')
expect(wrapper.find('button.moderate-user-button').exists()).toBe(true)
expect(wrapper.find('.el-dropdown-menu').exists()).toBe(true)
done()
@ -73,7 +78,9 @@ describe('Status show page', () => {
store,
localVue,
sync: false,
stubs: ['router-link'],
stubs: {
RouterLink: RouterLinkStub
},
mocks: {
$route
}
@ -81,7 +88,7 @@ describe('Status show page', () => {
await flushPromises()
expect(wrapper.find('.status-card').exists()).toBe(true)
expect(wrapper.find('router-link-stub span.status-account-name').text()).toBe('dolin')
expect(wrapper.findAllComponents(RouterLinkStub).at(1).find('span.status-account-name').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)

View file

@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import { mount, createLocalVue, config, RouterLinkStub } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import Element from 'element-ui'
import Users from '@/views/users/index'
@ -8,7 +8,8 @@ import { storeConfig } from './store.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
config.stubs['users-filter'] = '<div />'
config.stubs['users-filter'] = { template: '<div />'}
config.stubs.transition = false
const localVue = createLocalVue()
localVue.use(Vuex)
@ -31,7 +32,9 @@ describe('Search and filter users', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -44,7 +47,9 @@ describe('Search and filter users', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
wrapper.vm.handleDebounceSearchInput = (query) => {
@ -82,7 +87,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -101,7 +108,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -120,7 +129,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -136,7 +147,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -154,7 +167,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
expect(store.state.users.fetchedUsers[1].deactivated).toBe(false)
@ -172,7 +187,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -196,7 +213,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -214,7 +233,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -239,7 +260,9 @@ describe('Users actions', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -278,7 +301,9 @@ describe('Creates new account', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
@ -302,7 +327,9 @@ describe('Creates new account', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(4)
@ -336,7 +363,9 @@ describe('Creates new account', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
const validateEmailRule = { validator: wrapper.vm.validateEmail, field: 'email', fullField: 'email', type: 'string' }
@ -361,7 +390,9 @@ describe('Creates new account', () => {
store,
localVue,
sync: false,
stubs: ['router-link']
stubs: {
RouterLink: RouterLinkStub
}
})
await flushPromises()

View file

@ -1,5 +1,5 @@
import Vuex from 'vuex'
import { mount, createLocalVue, config } from '@vue/test-utils'
import { mount, createLocalVue, config, RouterLinkStub } from '@vue/test-utils'
import flushPromises from 'flush-promises'
import Element from 'element-ui'
import UsersShow from '@/views/users/show'
@ -7,6 +7,7 @@ import { storeConfig } from './store.conf'
import { cloneDeep } from 'lodash'
config.mocks["$t"] = () => {}
config.stubs.transition = false
const localVue = createLocalVue()
localVue.use(Vuex)
@ -33,7 +34,9 @@ describe('User profile', () => {
store,
localVue,
sync: false,
stubs: ['router-link'],
stubs: {
RouterLink: RouterLinkStub
},
mocks: {
$route
}