mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Add tests for users.vue
This commit is contained in:
parent
fe1759e582
commit
66e073e6de
2 changed files with 37 additions and 0 deletions
|
@ -28,6 +28,8 @@ import router from '@/router'
|
|||
import { alerts } from '@/utils'
|
||||
|
||||
export default {
|
||||
name: 'shared--user-item',
|
||||
|
||||
props: {
|
||||
user: {
|
||||
type: Object,
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import Component from '@/components/main-wrapper/main-content/users.vue'
|
||||
import UserItem from '@/components/shared/user-item.vue'
|
||||
import AddUserForm from '@/components/modals/add-user-form.vue'
|
||||
import EditUserForm from '@/components/modals/edit-user-form.vue'
|
||||
import factory from '@/tests/factory'
|
||||
import { userStore } from '@/stores'
|
||||
|
||||
describe('components/main-wrapper/main-content/users', () => {
|
||||
it('displays the users', () => {
|
||||
userStore.all = factory('user', 10)
|
||||
const wrapper = mount(Component)
|
||||
wrapper.findAll(UserItem).should.have.lengthOf(10)
|
||||
})
|
||||
|
||||
it('adds new user', () => {
|
||||
userStore.all = factory('user', 10)
|
||||
const wrapper = mount(Component)
|
||||
const openStub = sinon.stub(wrapper.vm.$refs.addUserForm, 'open')
|
||||
wrapper.contains(AddUserForm).should.be.true
|
||||
wrapper.find('.btn-add').trigger('click')
|
||||
openStub.called.should.be.true
|
||||
openStub.restore()
|
||||
})
|
||||
|
||||
it('edits a user', () => {
|
||||
userStore.all = factory('user', 10)
|
||||
const wrapper = mount(Component)
|
||||
const editStub = sinon.stub(wrapper.vm.$refs.editUserForm, 'open')
|
||||
wrapper.contains(EditUserForm).should.be.true
|
||||
wrapper.findAll('.btn-edit').at(0).trigger('click')
|
||||
editStub.calledWith(userStore.all[0]).should.be.true
|
||||
editStub.restore()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in a new issue