-
-
Notifications
You must be signed in to change notification settings - Fork 980
/
Copy pathUsers.spec.js
54 lines (50 loc) · 1.47 KB
/
Users.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { createLocalVue, shallowMount } from '@vue/test-utils'
import CoreuiVue from '@coreui/vue'
import Users from '@/views/users/Users'
import VueRouter from 'vue-router';
const localVue = createLocalVue()
localVue.use(VueRouter)
const router = new VueRouter()
localVue.use(CoreuiVue)
describe('Users.vue', () => {
it('has a name', () => {
expect(Users.name).toBe('Users')
})
it('has a created hook', () => {
expect(typeof Users.data).toMatch('function')
})
it('is Vue instance', () => {
const wrapper = shallowMount(Users,{
localVue,
router
})
expect(wrapper.isVueInstance()).toBe(true)
})
it('is Users', () => {
const wrapper = shallowMount(Users,{
localVue,
router
})
expect(wrapper.is(Users)).toBe(true)
})
test('renders correctly', () => {
const wrapper = shallowMount(Users, {
localVue,
router
})
expect(wrapper.element).toMatchSnapshot()
})
it('should have methods', () => {
const wrapper = shallowMount(Users,{
localVue,
router
})
expect(typeof Users.methods.userLink ).toEqual('function')
expect(Users.methods.userLink(42)).toBe('users/42')
expect(typeof Users.methods.rowClicked ).toEqual('function')
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')
})
})