-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToast.spec.js
89 lines (80 loc) · 2.39 KB
/
Toast.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import Toast from '../src/Toast.vue'
import Toaster from '../src/main.js'
import { createLocalVue, shallowMount } from '@vue/test-utils'
describe('Toast.vue', () => {
it('is an Object', () => {
expect(typeof Toast).toBe('object')
})
it('displays error toast', () => {
const localVue = createLocalVue()
localVue.use(Toaster)
const page = shallowMount(Toast, {
localVue,
propsData: {
toast: {
type: 'error',
title: 'Error',
message: 'Items could not be added'
}
}
})
expect(page.find('.flex-toast-error').is('div')).toBe(true)
expect(page.find('.toast-header').text()).toEqual('Error')
expect(page.find('.toast-body').text()).toEqual('Items could not be added')
})
it('displays info toast', () => {
const localVue = createLocalVue()
localVue.use(Toaster, {
timeout: 500
})
const page = shallowMount(Toast, {
localVue,
propsData: {
toast: {
type: 'info',
title: 'Info',
message: 'Info could not be added'
}
}
})
expect(page.find('.flex-toast-info').is('div')).toBe(true)
expect(page.find('.toast-header').text()).toEqual('Info')
expect(page.find('.toast-body').text()).toEqual('Info could not be added')
})
it('displays warning toast', () => {
const localVue = createLocalVue()
localVue.use(Toaster)
const page = shallowMount(Toast, {
localVue,
propsData: {
toast: {
type: 'warning',
title: 'Warning',
message: 'Warning could not be added',
timeout: 200
}
}
})
expect(page.find('.flex-toast-warning').is('div')).toBe(true)
expect(page.find('.toast-header').text()).toEqual('Warning')
expect(page.find('.toast-body').text()).toEqual('Warning could not be added')
})
it('displays success toast', () => {
const localVue = createLocalVue()
localVue.use(Toaster)
const page = shallowMount(Toast, {
localVue,
propsData: {
toast: {
type: 'success',
title: 'Success',
message: 'Items added successfully',
timeOut: 3500
}
}
})
expect(page.find('.flex-toast-success').is('div')).toBe(true)
expect(page.find('.toast-header').text()).toEqual('Success')
expect(page.find('.toast-body').text()).toEqual('Items added successfully')
})
})