Skip to content

Commit b8636c7

Browse files
author
Ganjar Setia M
authored
test: Improve test coverage to 100% for users views (#188)
1 parent 7eb5cd5 commit b8636c7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/unit/views/users/User.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ describe('User.vue', () => {
3535

3636
expect(typeof User.methods.goBack ).toEqual('function')
3737
expect(wrapper.vm.goBack()).toBeUndefined()
38+
expect(typeof User.methods.getUserData ).toEqual('function')
39+
expect(wrapper.vm.getUserData(1)).toStrictEqual([
40+
{ key: 'username', value: 'Samppa Nori' },
41+
{ key: 'registered', value: '2012/01/01' },
42+
{ key: 'role', value: 'Member' },
43+
{ key: 'status', value: 'Active' } ])
44+
expect(wrapper.vm.getUserData(30)).toStrictEqual([{"key": "id", "value": "Not found"}])
3845
})
3946
test('renders correctly', () => {
4047
const wrapper = shallowMount(User, {

tests/unit/views/users/Users.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ describe('Users.vue', () => {
4747
expect(Users.methods.userLink(42)).toBe('users/42')
4848
expect(typeof Users.methods.rowClicked ).toEqual('function')
4949
expect(wrapper.vm.rowClicked({id:42})).toBeUndefined()
50+
expect(typeof Users.methods.getBadge ).toEqual('function')
51+
expect(wrapper.vm.getBadge('Active')).toBe('success')
52+
expect(wrapper.vm.getBadge('Inactive')).toBe('secondary')
5053
})
5154
})

0 commit comments

Comments
 (0)