test: Improve test coverage to 100% for users views (#188)

This commit is contained in:
Ganjar Setia M
2020-01-29 16:52:19 +07:00
committed by GitHub
parent 7eb5cd5406
commit b8636c729f
2 changed files with 10 additions and 0 deletions
+7
View File
@@ -35,6 +35,13 @@ describe('User.vue', () => {
expect(typeof User.methods.goBack ).toEqual('function') expect(typeof User.methods.goBack ).toEqual('function')
expect(wrapper.vm.goBack()).toBeUndefined() expect(wrapper.vm.goBack()).toBeUndefined()
expect(typeof User.methods.getUserData ).toEqual('function')
expect(wrapper.vm.getUserData(1)).toStrictEqual([
{ key: 'username', value: 'Samppa Nori' },
{ key: 'registered', value: '2012/01/01' },
{ key: 'role', value: 'Member' },
{ key: 'status', value: 'Active' } ])
expect(wrapper.vm.getUserData(30)).toStrictEqual([{"key": "id", "value": "Not found"}])
}) })
test('renders correctly', () => { test('renders correctly', () => {
const wrapper = shallowMount(User, { const wrapper = shallowMount(User, {
+3
View File
@@ -47,5 +47,8 @@ describe('Users.vue', () => {
expect(Users.methods.userLink(42)).toBe('users/42') expect(Users.methods.userLink(42)).toBe('users/42')
expect(typeof Users.methods.rowClicked ).toEqual('function') expect(typeof Users.methods.rowClicked ).toEqual('function')
expect(wrapper.vm.rowClicked({id:42})).toBeUndefined() expect(wrapper.vm.rowClicked({id:42})).toBeUndefined()
expect(typeof Users.methods.getBadge ).toEqual('function')
expect(wrapper.vm.getBadge('Active')).toBe('success')
expect(wrapper.vm.getBadge('Inactive')).toBe('secondary')
}) })
}) })