This repository was archived by the owner on Dec 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppNumberSupporter.spec.ts
131 lines (119 loc) · 3.96 KB
/
AppNumberSupporter.spec.ts
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { shallowMount, mount, config } from '@vue/test-utils'
import AppNumberSupporter from '@/components/AppNumberSupporter.vue'
import { i18n } from '@/i18n'
describe('AppNumberSupporter.vue', () => {
it('renders all when passed', () => {
const value: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(1)`).classes('active')).toBeTruthy()
})
it('renders odd when passed', () => {
const value: number[] = [1, 3, 5, 7, 9]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(2)`).classes('active')).toBeTruthy()
})
it('renders even when passed', () => {
const value: number[] = [0, 2, 4, 6, 8]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(3)`).classes('active')).toBeTruthy()
})
it('renders big when passed', () => {
const value: number[] = [5, 6, 7, 8, 9]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(4)`).classes('active')).toBeTruthy()
})
it('renders small when passed', () => {
const value: number[] = [0, 1, 2, 3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(5)`).classes('active')).toBeTruthy()
})
it('renders clear when passed', () => {
const value: number[] = []
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
expect(wrapper.find(`div[role="radio"]:nth-child(6)`).classes('active')).toBeTruthy()
})
it('return data when click all', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(1)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
})
it('return data when click odd', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(2)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([1, 3, 5, 7, 9])
})
it('return data when click even', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(3)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([0, 2, 4, 6, 8])
})
it('return data when click big', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(4)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([5, 6, 7, 8, 9])
})
it('return data when click small', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(5)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([0, 1, 2, 3, 4])
})
it('return data when click clear', () => {
const value: number[] = [3, 4]
const wrapper = shallowMount(AppNumberSupporter, {
propsData: { value },
i18n,
sync: false
})
wrapper.find(`div[role="radio"]:nth-child(6)`).trigger('click')
expect(wrapper.emitted().input[0][0]).toEqual([])
})
})