@dimailn/vuetify 2.7.2-alpha29 → 2.7.2-alpha31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vuetify.js +166 -78
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js +8 -6
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/es5/components/VBreadcrumbs/VBreadcrumbsItem.js +4 -0
- package/es5/components/VBreadcrumbs/VBreadcrumbsItem.js.map +1 -1
- package/es5/components/VCarousel/VCarousel.js +14 -2
- package/es5/components/VCarousel/VCarousel.js.map +1 -1
- package/es5/components/VDialog/VDialog.js +47 -26
- package/es5/components/VDialog/VDialog.js.map +1 -1
- package/es5/components/VFileInput/VFileInput.js +50 -28
- package/es5/components/VFileInput/VFileInput.js.map +1 -1
- package/es5/components/VPagination/VPagination.js +15 -18
- package/es5/components/VPagination/VPagination.js.map +1 -1
- package/es5/components/VRangeSlider/VRangeSlider.js +57 -32
- package/es5/components/VRangeSlider/VRangeSlider.js.map +1 -1
- package/es5/components/VSubheader/VSubheader.js +1 -1
- package/es5/components/VSubheader/VSubheader.js.map +1 -1
- package/es5/components/VTreeview/VTreeview.js +26 -13
- package/es5/components/VTreeview/VTreeview.js.map +1 -1
- package/es5/components/VTreeview/VTreeviewNode.js +0 -2
- package/es5/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/es5/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/es5/framework.js +1 -1
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js +7 -5
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/lib/components/VBreadcrumbs/VBreadcrumbsItem.js +4 -0
- package/lib/components/VBreadcrumbs/VBreadcrumbsItem.js.map +1 -1
- package/lib/components/VCarousel/VCarousel.js +14 -2
- package/lib/components/VCarousel/VCarousel.js.map +1 -1
- package/lib/components/VDialog/VDialog.js +9 -2
- package/lib/components/VDialog/VDialog.js.map +1 -1
- package/lib/components/VFileInput/VFileInput.js +43 -26
- package/lib/components/VFileInput/VFileInput.js.map +1 -1
- package/lib/components/VPagination/VPagination.js +15 -19
- package/lib/components/VPagination/VPagination.js.map +1 -1
- package/lib/components/VRangeSlider/VRangeSlider.js +16 -4
- package/lib/components/VRangeSlider/VRangeSlider.js.map +1 -1
- package/lib/components/VSubheader/VSubheader.js +1 -1
- package/lib/components/VSubheader/VSubheader.js.map +1 -1
- package/lib/components/VTreeview/VTreeview.js +15 -7
- package/lib/components/VTreeview/VTreeview.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewNode.js +0 -2
- package/lib/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/lib/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/lib/framework.js +1 -1
- package/package.json +1 -1
- package/src/components/VBottomNavigation/__tests__/VBottomNavigation.spec.ts +43 -37
- package/src/components/VBottomNavigation/__tests__/__snapshots__/VBottomNavigation.spec.ts.snap +11 -10
- package/src/components/VBreadcrumbs/VBreadcrumbs.ts +8 -4
- package/src/components/VBreadcrumbs/VBreadcrumbsItem.ts +4 -0
- package/src/components/VBreadcrumbs/__tests__/VBreadcrumbs.spec.ts +125 -10
- package/src/components/VBreadcrumbs/__tests__/VBreadcrumbsItem.spec.ts +10 -6
- package/src/components/VBtnToggle/__tests__/VBtnToggle.spec.ts +10 -6
- package/src/components/VCarousel/VCarousel.ts +15 -3
- package/src/components/VCarousel/__tests__/VCarousel.spec.ts +74 -54
- package/src/components/VCarousel/__tests__/VCarouselItem.spec.ts +9 -5
- package/src/components/VCarousel/__tests__/__snapshots__/VCarousel.spec.ts.snap +1 -1
- package/src/components/VDialog/VDialog.ts +14 -4
- package/src/components/VDialog/__tests__/VDialog.spec.ts +105 -101
- package/src/components/VDialog/__tests__/__snapshots__/VDialog.spec.ts.snap +0 -15
- package/src/components/VExpansionPanel/__tests__/VExpansionPanel.spec.ts +43 -27
- package/src/components/VExpansionPanel/__tests__/__snapshots__/VExpansionPanel.spec.ts.snap +18 -16
- package/src/components/VFileInput/VFileInput.ts +46 -33
- package/src/components/VFileInput/__tests__/VFileInput.spec.ts +84 -54
- package/src/components/VFileInput/__tests__/__snapshots__/VFileInput.spec.ts.snap +242 -146
- package/src/components/VImg/__tests__/VImg.spec.ts +21 -20
- package/src/components/VImg/__tests__/__snapshots__/VImg.spec.ts.snap +16 -11
- package/src/components/VNavigationDrawer/__tests__/VNavigationDrawer.spec.ts +84 -71
- package/src/components/VPagination/VPagination.ts +16 -19
- package/src/components/VPagination/__tests__/VPagination.spec.ts +85 -71
- package/src/components/VPagination/__tests__/__snapshots__/VPagination.spec.ts.snap +184 -429
- package/src/components/VRangeSlider/VRangeSlider.ts +19 -4
- package/src/components/VRangeSlider/__tests__/VRangeSlider.spec.ts +40 -40
- package/src/components/VRangeSlider/__tests__/__snapshots__/VRangeSlider.spec.ts.snap +32 -38
- package/src/components/VSubheader/VSubheader.ts +1 -1
- package/src/components/VSubheader/__tests__/VSubheader.spec.ts +12 -7
- package/src/components/VSubheader/__tests__/__snapshots__/VSubheader.spec.ts.snap +1 -1
- package/src/components/VSystemBar/__tests__/VSystemBar.spec.ts +89 -17
- package/src/components/VTimeline/__tests__/VTimelineItem.spec.ts +25 -35
- package/src/components/VTimeline/__tests__/__snapshots__/VTimelineItem.spec.ts.snap +4 -5
- package/src/components/VTreeview/VTreeview.ts +20 -12
- package/src/components/VTreeview/VTreeviewNode.ts +0 -2
- package/src/components/VTreeview/__tests__/VTreeview.spec.ts +168 -174
- package/src/components/VTreeview/__tests__/VTreeviewNode.spec.ts +77 -66
- package/src/components/VTreeview/__tests__/__snapshots__/VTreeview.spec.ts.snap +141 -141
- package/src/components/VTreeview/__tests__/__snapshots__/VTreeviewNode.spec.ts.snap +26 -51
- package/src/components/VVirtualScroll/VVirtualScroll.ts +0 -1
- package/src/components/VVirtualScroll/__tests__/VVirtualScroll.spec.ts +6 -9
- package/src/components/VWindow/__tests__/VWindow.spec.ts +78 -0
- package/src/components/VWindow/__tests__/VWindowItem.spec.ts +127 -0
- package/src/components/VWindow/__tests__/__snapshots__/VWindow.spec.ts.snap +59 -0
- package/src/components/VWindow/__tests__/__snapshots__/VWindowItem.spec.ts.snap +36 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
1
|
import {
|
|
3
2
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
VueWrapper,
|
|
4
|
+
enableAutoUnmount,
|
|
5
|
+
MountingOptions,
|
|
6
6
|
} from '@vue/test-utils'
|
|
7
7
|
import VTreeview from '../VTreeview'
|
|
8
|
-
import { ExtractVue } from '../../../util/mixins'
|
|
9
8
|
import { wait } from '../../../../test'
|
|
9
|
+
import { h, nextTick } from 'vue'
|
|
10
|
+
|
|
11
|
+
// Types
|
|
12
|
+
import type { ComponentPublicInstance } from 'vue'
|
|
10
13
|
|
|
11
14
|
const singleRootTwoChildren = [
|
|
12
15
|
{ id: 0, name: 'Root', children: [{ id: 1, name: 'Child' }, { id: 2, name: 'Child 2' }] },
|
|
@@ -17,13 +20,26 @@ const threeLevels = [
|
|
|
17
20
|
]
|
|
18
21
|
|
|
19
22
|
describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
20
|
-
type Instance =
|
|
21
|
-
let mountFunction: (options?:
|
|
23
|
+
type Instance = InstanceType<typeof VTreeview>
|
|
24
|
+
let mountFunction: (options?: MountingOptions<Instance>) => VueWrapper<Instance>
|
|
25
|
+
|
|
26
|
+
enableAutoUnmount(afterEach)
|
|
27
|
+
|
|
22
28
|
beforeEach(() => {
|
|
23
|
-
mountFunction = (options
|
|
29
|
+
mountFunction = (options = {}) => {
|
|
24
30
|
return mount(VTreeview, {
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
global: {
|
|
32
|
+
mocks: {
|
|
33
|
+
$vuetify: {
|
|
34
|
+
rtl: false,
|
|
35
|
+
icons: {
|
|
36
|
+
values: {
|
|
37
|
+
subgroup: 'arrow_drop_down',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
27
43
|
...options,
|
|
28
44
|
})
|
|
29
45
|
}
|
|
@@ -31,7 +47,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
31
47
|
|
|
32
48
|
it('should render items', async () => {
|
|
33
49
|
const wrapper = mountFunction({
|
|
34
|
-
|
|
50
|
+
props: {
|
|
35
51
|
items: singleRootTwoChildren,
|
|
36
52
|
},
|
|
37
53
|
})
|
|
@@ -41,7 +57,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
41
57
|
|
|
42
58
|
it('should render items in dense mode', async () => {
|
|
43
59
|
const wrapper = mountFunction({
|
|
44
|
-
|
|
60
|
+
props: {
|
|
45
61
|
items: singleRootTwoChildren,
|
|
46
62
|
dense: true,
|
|
47
63
|
},
|
|
@@ -54,20 +70,17 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
54
70
|
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
55
71
|
it.skip('should select all leaf nodes', async () => {
|
|
56
72
|
const wrapper = mountFunction({
|
|
57
|
-
|
|
73
|
+
props: {
|
|
58
74
|
items: threeLevels,
|
|
59
75
|
selectable: true,
|
|
60
76
|
},
|
|
61
77
|
})
|
|
62
78
|
|
|
63
|
-
const fn = jest.fn()
|
|
64
|
-
wrapper.vm.$on('input', fn)
|
|
65
|
-
|
|
66
79
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
67
|
-
await
|
|
80
|
+
await nextTick()
|
|
68
81
|
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
82
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(1)
|
|
83
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([[3, 2]])
|
|
71
84
|
expect(wrapper.html()).toMatchSnapshot()
|
|
72
85
|
})
|
|
73
86
|
|
|
@@ -75,23 +88,20 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
75
88
|
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
76
89
|
it.skip('should select only leaf nodes', async () => {
|
|
77
90
|
const wrapper = mountFunction({
|
|
78
|
-
|
|
91
|
+
props: {
|
|
79
92
|
items: threeLevels,
|
|
80
93
|
selectable: true,
|
|
81
94
|
},
|
|
82
95
|
})
|
|
83
96
|
|
|
84
|
-
const fn = jest.fn()
|
|
85
|
-
wrapper.vm.$on('input', fn)
|
|
86
|
-
|
|
87
97
|
wrapper.find('.v-treeview-node__toggle').trigger('click')
|
|
88
|
-
await
|
|
98
|
+
await nextTick()
|
|
89
99
|
|
|
90
|
-
wrapper.findAll('.v-treeview-node__checkbox')
|
|
91
|
-
await
|
|
100
|
+
wrapper.findAll('.v-treeview-node__checkbox')[2].trigger('click')
|
|
101
|
+
await nextTick()
|
|
92
102
|
|
|
93
|
-
expect(
|
|
94
|
-
expect(
|
|
103
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(1)
|
|
104
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([[3]])
|
|
95
105
|
expect(wrapper.html()).toMatchSnapshot()
|
|
96
106
|
})
|
|
97
107
|
|
|
@@ -99,21 +109,18 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
99
109
|
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
100
110
|
it.skip('should select only root node', async () => {
|
|
101
111
|
const wrapper = mountFunction({
|
|
102
|
-
|
|
112
|
+
props: {
|
|
103
113
|
items: threeLevels,
|
|
104
114
|
selectable: true,
|
|
105
115
|
selectionType: 'independent',
|
|
106
116
|
},
|
|
107
117
|
})
|
|
108
118
|
|
|
109
|
-
const fn = jest.fn()
|
|
110
|
-
wrapper.vm.$on('input', fn)
|
|
111
|
-
|
|
112
119
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
113
|
-
await
|
|
120
|
+
await nextTick()
|
|
114
121
|
|
|
115
|
-
expect(
|
|
116
|
-
expect(
|
|
122
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(1)
|
|
123
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([[0]])
|
|
117
124
|
expect(wrapper.html()).toMatchSnapshot()
|
|
118
125
|
})
|
|
119
126
|
|
|
@@ -124,7 +131,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
const wrapper = mountFunction({
|
|
127
|
-
|
|
134
|
+
props: {
|
|
128
135
|
items: [{ id: 0, name: 'Root', children: [] }],
|
|
129
136
|
loadChildren,
|
|
130
137
|
},
|
|
@@ -133,7 +140,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
133
140
|
expect(wrapper.html()).toMatchSnapshot()
|
|
134
141
|
|
|
135
142
|
wrapper.find('.v-treeview-node__toggle').trigger('click')
|
|
136
|
-
await
|
|
143
|
+
await nextTick()
|
|
137
144
|
|
|
138
145
|
expect(wrapper.html()).toMatchSnapshot()
|
|
139
146
|
expect(`[Vue warn]: Error in created hook: "TypeError: Cannot set property 'vnode' of undefined"`).toHaveBeenWarned()
|
|
@@ -146,74 +153,66 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
const wrapper = mountFunction({
|
|
149
|
-
|
|
156
|
+
props: {
|
|
150
157
|
items: [{ id: 0, name: 'Root', children: [] }],
|
|
151
158
|
selectable: true,
|
|
152
159
|
loadChildren,
|
|
153
160
|
},
|
|
154
161
|
})
|
|
155
162
|
|
|
156
|
-
const fn = jest.fn()
|
|
157
|
-
wrapper.vm.$on('input', fn)
|
|
158
|
-
|
|
159
163
|
expect(wrapper.html()).toMatchSnapshot()
|
|
160
164
|
|
|
161
165
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
162
166
|
await wait()
|
|
163
167
|
|
|
164
|
-
expect(
|
|
165
|
-
expect(
|
|
168
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(1)
|
|
169
|
+
expect(wrapper.emitted('update:modelValue')[0]).toEqual([[1]])
|
|
166
170
|
expect(wrapper.html()).toMatchSnapshot()
|
|
167
171
|
})
|
|
168
172
|
|
|
169
173
|
it('should emit active node when clicking on it', async () => {
|
|
170
174
|
const wrapper = mountFunction({
|
|
171
|
-
|
|
175
|
+
props: {
|
|
172
176
|
items: [{ id: 0, name: 'Root' }, { id: 1, name: 'Root' }],
|
|
173
177
|
activatable: true,
|
|
174
178
|
},
|
|
175
179
|
})
|
|
176
180
|
|
|
177
|
-
const fn = jest.fn()
|
|
178
|
-
wrapper.vm.$on('update:active', fn)
|
|
179
|
-
|
|
180
181
|
wrapper.find('.v-treeview-node__root').trigger('click')
|
|
181
|
-
await
|
|
182
|
+
await nextTick()
|
|
182
183
|
|
|
183
|
-
expect(
|
|
184
|
-
expect(
|
|
184
|
+
expect(wrapper.emitted('update:active')).toHaveLength(1)
|
|
185
|
+
expect(wrapper.emitted('update:active')[0]).toEqual([[0]])
|
|
185
186
|
|
|
186
187
|
wrapper.find('.v-treeview-node__root').trigger('click')
|
|
187
|
-
await
|
|
188
|
+
await nextTick()
|
|
188
189
|
|
|
189
|
-
expect(
|
|
190
|
+
expect(wrapper.emitted('update:active')).toHaveLength(2)
|
|
191
|
+
expect(wrapper.emitted('update:active')[1]).toEqual([[]])
|
|
190
192
|
})
|
|
191
193
|
|
|
192
194
|
it('should allow multiple active nodes with prop multipleActive', async () => {
|
|
193
195
|
const wrapper = mountFunction({
|
|
194
|
-
|
|
196
|
+
props: {
|
|
195
197
|
items: [{ id: 0, name: 'Root' }, { id: 1, name: 'Root' }],
|
|
196
198
|
multipleActive: true,
|
|
197
199
|
activatable: true,
|
|
198
200
|
},
|
|
199
201
|
})
|
|
200
202
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
wrapper.findAll('.v-treeview-node__root').wrappers.forEach(vm => vm.trigger('click'))
|
|
205
|
-
await wrapper.vm.$nextTick()
|
|
203
|
+
wrapper.findAll('.v-treeview-node__root').forEach(vm => vm.trigger('click'))
|
|
204
|
+
await nextTick()
|
|
206
205
|
|
|
207
|
-
expect(
|
|
208
|
-
expect(
|
|
206
|
+
expect(wrapper.emitted('update:active')).toHaveLength(2)
|
|
207
|
+
expect(wrapper.emitted('update:active')[1]).toEqual([[0, 1]])
|
|
209
208
|
})
|
|
210
209
|
|
|
211
210
|
// TODO: fails with TS 3.9
|
|
212
211
|
it.skip('should update selection when selected prop changes', async () => {
|
|
213
212
|
const wrapper = mountFunction({
|
|
214
|
-
|
|
213
|
+
props: {
|
|
215
214
|
items: [{ id: 0, name: 'Root', children: [{ id: 1, name: 'Child' }] }],
|
|
216
|
-
|
|
215
|
+
modelValue: [],
|
|
217
216
|
selectable: true,
|
|
218
217
|
},
|
|
219
218
|
})
|
|
@@ -221,76 +220,78 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
221
220
|
expect(wrapper.html()).toMatchSnapshot()
|
|
222
221
|
|
|
223
222
|
wrapper.find('.v-treeview-node__toggle').trigger('click')
|
|
224
|
-
wrapper.setProps({
|
|
225
|
-
await
|
|
223
|
+
wrapper.setProps({ modelValue: [1] })
|
|
224
|
+
await nextTick()
|
|
226
225
|
|
|
227
226
|
expect(wrapper.findAll('.v-treeview-node')).toHaveLength(2)
|
|
228
227
|
expect(wrapper.findAll('.v-treeview-node--selected')).toHaveLength(2)
|
|
229
228
|
expect(wrapper.html()).toMatchSnapshot()
|
|
230
229
|
|
|
231
|
-
wrapper.setProps({
|
|
232
|
-
await
|
|
230
|
+
wrapper.setProps({ modelValue: [] })
|
|
231
|
+
await nextTick()
|
|
233
232
|
expect(wrapper.html()).toMatchSnapshot()
|
|
234
233
|
})
|
|
235
234
|
|
|
236
235
|
it('should open all children when using open-all prop', async () => {
|
|
237
236
|
const wrapper = mountFunction({
|
|
238
|
-
|
|
237
|
+
props: {
|
|
239
238
|
items: threeLevels,
|
|
240
239
|
openAll: true,
|
|
241
240
|
},
|
|
242
241
|
})
|
|
243
242
|
|
|
244
|
-
await
|
|
243
|
+
await nextTick()
|
|
245
244
|
|
|
246
245
|
expect(wrapper.html()).toMatchSnapshot()
|
|
247
246
|
})
|
|
248
247
|
|
|
249
248
|
it('should open/close all children when using updateAll', async () => {
|
|
249
|
+
const updateOpen = jest.fn()
|
|
250
250
|
const wrapper = mountFunction({
|
|
251
|
-
|
|
251
|
+
props: {
|
|
252
252
|
items: threeLevels,
|
|
253
253
|
},
|
|
254
|
+
attrs: {
|
|
255
|
+
'onUpdate:open': updateOpen,
|
|
256
|
+
},
|
|
254
257
|
})
|
|
255
258
|
|
|
256
|
-
const updateOpen = jest.fn()
|
|
257
|
-
wrapper.vm.$on('update:open', updateOpen)
|
|
258
|
-
|
|
259
259
|
wrapper.vm.updateAll(true)
|
|
260
|
-
expect(updateOpen).toHaveBeenCalledTimes(
|
|
260
|
+
expect(updateOpen).toHaveBeenCalledTimes(2)
|
|
261
261
|
expect(updateOpen).toHaveBeenCalledWith([0, 1])
|
|
262
262
|
|
|
263
263
|
wrapper.vm.updateAll(false)
|
|
264
|
-
expect(updateOpen).toHaveBeenCalledTimes(
|
|
264
|
+
expect(updateOpen).toHaveBeenCalledTimes(3)
|
|
265
265
|
expect(updateOpen).toHaveBeenCalledWith([])
|
|
266
266
|
})
|
|
267
267
|
|
|
268
268
|
it('should react to open changes', async () => {
|
|
269
|
+
const fn = jest.fn()
|
|
269
270
|
const wrapper = mountFunction({
|
|
270
|
-
|
|
271
|
+
props: {
|
|
271
272
|
items: threeLevels,
|
|
272
273
|
open: [1],
|
|
273
274
|
},
|
|
275
|
+
attrs: {
|
|
276
|
+
'onUpdate:open': fn,
|
|
277
|
+
},
|
|
274
278
|
})
|
|
275
279
|
|
|
276
|
-
const fn = jest.fn()
|
|
277
|
-
|
|
278
|
-
wrapper.vm.$on('update:open', fn)
|
|
279
280
|
wrapper.setProps({ open: [0, 1] })
|
|
280
281
|
|
|
281
|
-
await
|
|
282
|
+
await nextTick()
|
|
282
283
|
|
|
283
284
|
expect(wrapper.html()).toMatchSnapshot()
|
|
284
285
|
|
|
285
286
|
wrapper.setProps({ open: [0] })
|
|
286
287
|
|
|
287
|
-
await
|
|
288
|
+
await nextTick()
|
|
288
289
|
|
|
289
290
|
expect(wrapper.html()).toMatchSnapshot()
|
|
290
291
|
|
|
291
292
|
wrapper.setProps({ open: [0, 1] })
|
|
292
293
|
|
|
293
|
-
await
|
|
294
|
+
await nextTick()
|
|
294
295
|
|
|
295
296
|
expect(wrapper.html()).toMatchSnapshot()
|
|
296
297
|
|
|
@@ -299,7 +300,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
299
300
|
// Should not update open values that do not exist in the tree
|
|
300
301
|
wrapper.setProps({ open: [7] })
|
|
301
302
|
|
|
302
|
-
await
|
|
303
|
+
await nextTick()
|
|
303
304
|
expect(wrapper.html()).toMatchSnapshot()
|
|
304
305
|
|
|
305
306
|
expect(fn).toHaveBeenCalledWith([])
|
|
@@ -307,10 +308,10 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
307
308
|
|
|
308
309
|
it('should update selected and active on created', async () => {
|
|
309
310
|
const wrapper = mountFunction({
|
|
310
|
-
|
|
311
|
+
props: {
|
|
311
312
|
items: threeLevels,
|
|
312
313
|
active: [2],
|
|
313
|
-
|
|
314
|
+
modelValue: [1],
|
|
314
315
|
},
|
|
315
316
|
})
|
|
316
317
|
|
|
@@ -323,98 +324,89 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
323
324
|
})
|
|
324
325
|
|
|
325
326
|
it('should react to changes for active items', async () => {
|
|
327
|
+
const active = jest.fn()
|
|
326
328
|
const wrapper = mountFunction({
|
|
327
|
-
|
|
329
|
+
props: {
|
|
328
330
|
items: threeLevels,
|
|
329
331
|
active: [2],
|
|
330
332
|
},
|
|
333
|
+
attrs: {
|
|
334
|
+
'onUpdate:active': active,
|
|
335
|
+
},
|
|
331
336
|
})
|
|
332
337
|
|
|
333
|
-
const active = jest.fn()
|
|
334
|
-
wrapper.vm.$on('update:active', active)
|
|
335
|
-
|
|
336
338
|
wrapper.setProps({ active: [] })
|
|
337
|
-
await
|
|
339
|
+
await nextTick()
|
|
338
340
|
expect(active).toHaveBeenCalledWith([])
|
|
339
341
|
|
|
340
342
|
// without multiple-active, it will use last value in array
|
|
341
343
|
wrapper.setProps({ active: [1, 3] })
|
|
342
|
-
await
|
|
344
|
+
await nextTick()
|
|
343
345
|
expect(active).toHaveBeenCalledWith([3])
|
|
344
346
|
|
|
345
347
|
wrapper.setProps({ multipleActive: true, active: [1, 3] })
|
|
346
|
-
await
|
|
348
|
+
await nextTick()
|
|
347
349
|
expect(active).toHaveBeenCalledWith([1, 3])
|
|
348
350
|
|
|
349
351
|
// 7 does not exist, we get nothing back
|
|
350
352
|
wrapper.setProps({ active: [7] })
|
|
351
|
-
await
|
|
353
|
+
await nextTick()
|
|
352
354
|
expect(active).toHaveBeenCalledWith([])
|
|
353
355
|
|
|
354
356
|
wrapper.setProps({ active: [0], items: singleRootTwoChildren })
|
|
355
|
-
await
|
|
357
|
+
await nextTick()
|
|
356
358
|
expect(active).toHaveBeenCalledWith([0])
|
|
357
359
|
})
|
|
358
360
|
|
|
359
361
|
it('should react to changes for selected items', async () => {
|
|
362
|
+
const value = jest.fn()
|
|
360
363
|
const wrapper = mountFunction({
|
|
361
|
-
|
|
364
|
+
props: {
|
|
362
365
|
items: threeLevels,
|
|
363
|
-
|
|
366
|
+
modelValue: [2],
|
|
367
|
+
},
|
|
368
|
+
attrs: {
|
|
369
|
+
'onUpdate:modelValue': value,
|
|
364
370
|
},
|
|
365
371
|
})
|
|
366
372
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
wrapper.setProps({ value: [] })
|
|
371
|
-
await wrapper.vm.$nextTick()
|
|
373
|
+
wrapper.setProps({ modelValue: [] })
|
|
374
|
+
await nextTick()
|
|
372
375
|
expect(value).toHaveBeenCalledWith([])
|
|
373
376
|
|
|
374
|
-
wrapper.setProps({
|
|
375
|
-
await
|
|
377
|
+
wrapper.setProps({ modelValue: [3] })
|
|
378
|
+
await nextTick()
|
|
376
379
|
expect(value).toHaveBeenCalledWith([3])
|
|
377
380
|
|
|
378
381
|
// 7 does not exist, we get nothing back
|
|
379
|
-
wrapper.setProps({
|
|
380
|
-
await
|
|
382
|
+
wrapper.setProps({ modelValue: [7] })
|
|
383
|
+
await nextTick()
|
|
381
384
|
expect(value).toHaveBeenCalledWith([])
|
|
382
385
|
|
|
383
|
-
wrapper.setProps({
|
|
384
|
-
await
|
|
386
|
+
wrapper.setProps({ modelValue: [0] })
|
|
387
|
+
await nextTick()
|
|
385
388
|
expect(value).toHaveBeenLastCalledWith([3, 2])
|
|
386
389
|
})
|
|
387
390
|
|
|
388
391
|
it('should accept string value for id', async () => {
|
|
389
392
|
const wrapper = mountFunction({
|
|
390
|
-
|
|
393
|
+
props: { itemKey: 'name' },
|
|
391
394
|
})
|
|
392
395
|
|
|
393
396
|
wrapper.setProps({ items: [{ name: 'Foobar' }] })
|
|
394
397
|
|
|
395
|
-
await
|
|
398
|
+
await nextTick()
|
|
396
399
|
|
|
397
400
|
expect(wrapper.vm.nodes.Foobar).toBeTruthy()
|
|
398
401
|
|
|
399
|
-
wrapper.setProps({
|
|
402
|
+
wrapper.setProps({ modelValue: ['Foobar'] })
|
|
400
403
|
|
|
401
|
-
await
|
|
402
|
-
})
|
|
403
|
-
|
|
404
|
-
it('should warn developer when using non-scoped slots', () => {
|
|
405
|
-
mountFunction({
|
|
406
|
-
slots: {
|
|
407
|
-
prepend: [{ render: h => h('div') }],
|
|
408
|
-
append: [{ render: h => h('div') }],
|
|
409
|
-
},
|
|
410
|
-
})
|
|
411
|
-
|
|
412
|
-
expect('[Vuetify] The prepend and append slots require a slot-scope attribute').toHaveBeenTipped()
|
|
404
|
+
await nextTick()
|
|
413
405
|
})
|
|
414
406
|
|
|
415
407
|
it('should not show expand icon when children is empty', () => {
|
|
416
408
|
const wrapper = mountFunction({
|
|
417
|
-
|
|
409
|
+
props: {
|
|
418
410
|
items: [
|
|
419
411
|
{
|
|
420
412
|
text: 'root',
|
|
@@ -430,7 +422,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
430
422
|
|
|
431
423
|
it('should show expand icon when children is empty and load-children prop used', () => {
|
|
432
424
|
const wrapper = mountFunction({
|
|
433
|
-
|
|
425
|
+
props: {
|
|
434
426
|
loadChildren: () => {},
|
|
435
427
|
items: [
|
|
436
428
|
{
|
|
@@ -455,7 +447,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
455
447
|
]
|
|
456
448
|
|
|
457
449
|
const wrapper = mountFunction({
|
|
458
|
-
|
|
450
|
+
props: {
|
|
459
451
|
items,
|
|
460
452
|
itemChildren: '__children',
|
|
461
453
|
loadChildren: () => {
|
|
@@ -469,14 +461,14 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
469
461
|
})
|
|
470
462
|
|
|
471
463
|
wrapper.find('.v-treeview-node__toggle').trigger('click')
|
|
472
|
-
await
|
|
464
|
+
await nextTick()
|
|
473
465
|
|
|
474
466
|
expect(wrapper.html()).toMatchSnapshot()
|
|
475
467
|
})
|
|
476
468
|
|
|
477
469
|
it('should remove old nodes', async () => {
|
|
478
470
|
const wrapper = mountFunction({
|
|
479
|
-
|
|
471
|
+
props: {
|
|
480
472
|
items: [
|
|
481
473
|
{
|
|
482
474
|
id: 1,
|
|
@@ -501,7 +493,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
501
493
|
],
|
|
502
494
|
})
|
|
503
495
|
|
|
504
|
-
await
|
|
496
|
+
await nextTick()
|
|
505
497
|
expect(wrapper.html()).toMatchSnapshot()
|
|
506
498
|
|
|
507
499
|
wrapper.setProps({
|
|
@@ -517,7 +509,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
517
509
|
],
|
|
518
510
|
})
|
|
519
511
|
|
|
520
|
-
await
|
|
512
|
+
await nextTick()
|
|
521
513
|
expect(wrapper.html()).toMatchSnapshot()
|
|
522
514
|
|
|
523
515
|
expect(Object.keys(wrapper.vm.nodes)).toHaveLength(2)
|
|
@@ -525,7 +517,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
525
517
|
|
|
526
518
|
it('should filter items', async () => {
|
|
527
519
|
const wrapper = mountFunction({
|
|
528
|
-
|
|
520
|
+
props: {
|
|
529
521
|
items: [
|
|
530
522
|
{
|
|
531
523
|
id: 1,
|
|
@@ -545,14 +537,14 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
545
537
|
search: 'two',
|
|
546
538
|
})
|
|
547
539
|
|
|
548
|
-
await
|
|
540
|
+
await nextTick()
|
|
549
541
|
|
|
550
542
|
expect(wrapper.html()).toMatchSnapshot()
|
|
551
543
|
})
|
|
552
544
|
|
|
553
545
|
it('should filter items using custom item filter', async () => {
|
|
554
546
|
const wrapper = mountFunction({
|
|
555
|
-
|
|
547
|
+
props: {
|
|
556
548
|
filter: (item, search, textKey) => item.special === search,
|
|
557
549
|
items: [
|
|
558
550
|
{
|
|
@@ -576,7 +568,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
576
568
|
search: 'yes',
|
|
577
569
|
})
|
|
578
570
|
|
|
579
|
-
await
|
|
571
|
+
await nextTick()
|
|
580
572
|
|
|
581
573
|
expect(wrapper.html()).toMatchSnapshot()
|
|
582
574
|
})
|
|
@@ -585,36 +577,38 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
585
577
|
it.skip('should emit objects when return-object prop is used', async () => {
|
|
586
578
|
const items = [{ id: 0, name: 'Root', children: [{ id: 1, name: 'Child' }] }]
|
|
587
579
|
|
|
580
|
+
const active = jest.fn()
|
|
581
|
+
const selected = jest.fn()
|
|
582
|
+
const open = jest.fn()
|
|
583
|
+
|
|
588
584
|
const wrapper = mountFunction({
|
|
589
|
-
|
|
585
|
+
props: {
|
|
590
586
|
items,
|
|
591
587
|
activatable: true,
|
|
592
588
|
selectable: true,
|
|
593
589
|
returnObject: true,
|
|
594
590
|
},
|
|
591
|
+
attrs: {
|
|
592
|
+
'onUpdate:active': active,
|
|
593
|
+
'onUpdate:modelValue': selected,
|
|
594
|
+
'onUpdate:open': open,
|
|
595
|
+
},
|
|
595
596
|
})
|
|
596
597
|
|
|
597
|
-
const active = jest.fn()
|
|
598
|
-
wrapper.vm.$on('update:active', active)
|
|
599
|
-
const selected = jest.fn()
|
|
600
|
-
wrapper.vm.$on('input', selected)
|
|
601
|
-
const open = jest.fn()
|
|
602
|
-
wrapper.vm.$on('update:open', open)
|
|
603
|
-
|
|
604
598
|
wrapper.find('.v-treeview-node__root').trigger('click')
|
|
605
|
-
await
|
|
599
|
+
await nextTick()
|
|
606
600
|
|
|
607
601
|
expect(active).toHaveBeenCalledTimes(1)
|
|
608
602
|
expect(active).toHaveBeenCalledWith([items[0]])
|
|
609
603
|
|
|
610
604
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
611
|
-
await
|
|
605
|
+
await nextTick()
|
|
612
606
|
|
|
613
607
|
expect(selected).toHaveBeenCalledTimes(1)
|
|
614
608
|
expect(selected).toHaveBeenCalledWith([items[0].children[0]])
|
|
615
609
|
|
|
616
610
|
wrapper.find('.v-treeview-node__toggle').trigger('click')
|
|
617
|
-
await
|
|
611
|
+
await nextTick()
|
|
618
612
|
|
|
619
613
|
expect(open).toHaveBeenCalledTimes(1)
|
|
620
614
|
expect(open).toHaveBeenCalledWith([items[0]])
|
|
@@ -622,7 +616,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
622
616
|
|
|
623
617
|
it('should handle replacing items with new array of equal length', async () => {
|
|
624
618
|
const wrapper = mountFunction({
|
|
625
|
-
|
|
619
|
+
props: {
|
|
626
620
|
items: [
|
|
627
621
|
{
|
|
628
622
|
id: 1,
|
|
@@ -651,7 +645,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
651
645
|
],
|
|
652
646
|
})
|
|
653
647
|
|
|
654
|
-
await
|
|
648
|
+
await nextTick()
|
|
655
649
|
|
|
656
650
|
expect(wrapper.html()).toMatchSnapshot()
|
|
657
651
|
})
|
|
@@ -663,18 +657,18 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
663
657
|
const two = { id: '2', name: 'Two', children: [three] }
|
|
664
658
|
|
|
665
659
|
const wrapper = mountFunction({
|
|
666
|
-
|
|
660
|
+
props: {
|
|
667
661
|
returnObject: true,
|
|
668
662
|
selectable: true,
|
|
669
663
|
activatable: true,
|
|
670
664
|
items: [one, two],
|
|
671
|
-
|
|
665
|
+
modelValue: [one],
|
|
672
666
|
open: [two],
|
|
673
667
|
active: [three],
|
|
674
668
|
},
|
|
675
669
|
})
|
|
676
670
|
|
|
677
|
-
await
|
|
671
|
+
await nextTick()
|
|
678
672
|
|
|
679
673
|
expect(wrapper.html()).toMatchSnapshot()
|
|
680
674
|
})
|
|
@@ -690,9 +684,9 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
690
684
|
name: 'Foo',
|
|
691
685
|
}
|
|
692
686
|
const wrapper = mountFunction({
|
|
693
|
-
|
|
687
|
+
props: {
|
|
694
688
|
items: [{ ...item, children }],
|
|
695
|
-
|
|
689
|
+
modelValue: [4],
|
|
696
690
|
},
|
|
697
691
|
})
|
|
698
692
|
|
|
@@ -706,7 +700,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
706
700
|
}],
|
|
707
701
|
})
|
|
708
702
|
|
|
709
|
-
await
|
|
703
|
+
await nextTick()
|
|
710
704
|
|
|
711
705
|
expect(wrapper.vm.nodes['5'].isIndeterminate).toBeUndefined()
|
|
712
706
|
})
|
|
@@ -726,14 +720,14 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
726
720
|
const input = jest.fn()
|
|
727
721
|
|
|
728
722
|
const wrapper = mountFunction({
|
|
729
|
-
|
|
723
|
+
props: {
|
|
730
724
|
items,
|
|
731
|
-
|
|
725
|
+
modelValue: [2, 3, 4],
|
|
732
726
|
selectionType: 'leaf',
|
|
733
727
|
selectable: true,
|
|
734
728
|
},
|
|
735
|
-
|
|
736
|
-
input,
|
|
729
|
+
attrs: {
|
|
730
|
+
'onUpdate:modelValue': input,
|
|
737
731
|
},
|
|
738
732
|
})
|
|
739
733
|
|
|
@@ -749,7 +743,7 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
749
743
|
}],
|
|
750
744
|
})
|
|
751
745
|
|
|
752
|
-
await
|
|
746
|
+
await nextTick()
|
|
753
747
|
|
|
754
748
|
expect(input).not.toHaveBeenCalled()
|
|
755
749
|
})
|
|
@@ -770,24 +764,24 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
770
764
|
const input = jest.fn()
|
|
771
765
|
|
|
772
766
|
const wrapper = mountFunction({
|
|
773
|
-
|
|
767
|
+
props: {
|
|
774
768
|
items,
|
|
775
|
-
|
|
769
|
+
modelValue: [],
|
|
776
770
|
selectionType: 'leaf',
|
|
777
771
|
selectable: true,
|
|
778
772
|
},
|
|
779
|
-
|
|
780
|
-
input,
|
|
773
|
+
attrs: {
|
|
774
|
+
'onUpdate:modelValue': input,
|
|
781
775
|
},
|
|
782
776
|
})
|
|
783
777
|
|
|
784
778
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
785
|
-
await
|
|
779
|
+
await nextTick()
|
|
786
780
|
|
|
787
781
|
expect(input).toHaveBeenLastCalledWith([3, 4])
|
|
788
782
|
|
|
789
783
|
wrapper.setProps({
|
|
790
|
-
|
|
784
|
+
modelValue: [2, 3, 4],
|
|
791
785
|
items: [{
|
|
792
786
|
id: 1,
|
|
793
787
|
name: 'Foo',
|
|
@@ -798,10 +792,10 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
798
792
|
],
|
|
799
793
|
}],
|
|
800
794
|
})
|
|
801
|
-
await
|
|
795
|
+
await nextTick()
|
|
802
796
|
|
|
803
797
|
wrapper.find('.v-treeview-node__checkbox').trigger('click')
|
|
804
|
-
await
|
|
798
|
+
await nextTick()
|
|
805
799
|
|
|
806
800
|
expect(input).toHaveBeenLastCalledWith([2])
|
|
807
801
|
})
|
|
@@ -824,27 +818,27 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
824
818
|
const input = jest.fn()
|
|
825
819
|
|
|
826
820
|
const wrapper = mountFunction({
|
|
827
|
-
|
|
821
|
+
props: {
|
|
828
822
|
items,
|
|
829
|
-
|
|
823
|
+
modelValue: [],
|
|
830
824
|
open: [1],
|
|
831
825
|
selectionType: 'independent',
|
|
832
826
|
selectable: true,
|
|
833
827
|
},
|
|
834
|
-
|
|
835
|
-
input,
|
|
828
|
+
attrs: {
|
|
829
|
+
'onUpdate:modelValue': input,
|
|
836
830
|
},
|
|
837
831
|
})
|
|
838
832
|
|
|
839
|
-
await
|
|
833
|
+
await nextTick()
|
|
840
834
|
|
|
841
835
|
wrapper.findAll('.v-treeview-node__checkbox').at(1).trigger('click')
|
|
842
|
-
await
|
|
836
|
+
await nextTick()
|
|
843
837
|
|
|
844
838
|
expect(input).toHaveBeenLastCalledWith([2])
|
|
845
839
|
|
|
846
840
|
wrapper.findAll('.v-treeview-node__checkbox').at(2).trigger('click')
|
|
847
|
-
await
|
|
841
|
+
await nextTick()
|
|
848
842
|
|
|
849
843
|
expect(input).toHaveBeenCalledTimes(1)
|
|
850
844
|
})
|
|
@@ -855,22 +849,22 @@ describe('VTreeView.ts', () => { // eslint-disable-line max-statements
|
|
|
855
849
|
const open = jest.fn()
|
|
856
850
|
|
|
857
851
|
const wrapper = mountFunction({
|
|
858
|
-
|
|
852
|
+
props: {
|
|
859
853
|
items: [{ id: 0, name: 'Root', children: [] }],
|
|
860
854
|
loadChildren: () => wrapper.setProps({
|
|
861
855
|
items: [{ id: 0, name: 'Root', children: [{ id: 1, name: 'Child' }] }],
|
|
862
856
|
}),
|
|
863
857
|
openOnClick: true,
|
|
864
858
|
},
|
|
865
|
-
|
|
866
|
-
'
|
|
859
|
+
attrs: {
|
|
860
|
+
'onUpdate:open': open,
|
|
867
861
|
},
|
|
868
862
|
})
|
|
869
863
|
|
|
870
864
|
expect(wrapper.html()).toMatchSnapshot()
|
|
871
865
|
|
|
872
866
|
wrapper.find('.v-treeview-node__root').trigger('click')
|
|
873
|
-
await
|
|
867
|
+
await nextTick()
|
|
874
868
|
|
|
875
869
|
expect(wrapper.html()).toMatchSnapshot()
|
|
876
870
|
expect(open).toHaveBeenLastCalledWith([0])
|