@dimailn/vuetify 2.7.2-alpha27 → 2.7.2-alpha28
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 +78 -22
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VAlert/VAlert.js +0 -1
- package/es5/components/VAlert/VAlert.js.map +1 -1
- package/es5/components/VChip/VChip.js +1 -0
- package/es5/components/VChip/VChip.js.map +1 -1
- package/es5/components/VList/VListItem.js +4 -2
- package/es5/components/VList/VListItem.js.map +1 -1
- package/es5/components/VMenu/VMenu.js +1 -1
- package/es5/components/VMenu/VMenu.js.map +1 -1
- package/es5/components/VOtpInput/VOtpInput.js +36 -0
- package/es5/components/VOtpInput/VOtpInput.js.map +1 -1
- package/es5/components/VSelect/VSelectList.js +15 -2
- package/es5/components/VSelect/VSelectList.js.map +1 -1
- package/es5/components/VTooltip/VTooltip.js +3 -3
- package/es5/components/VTooltip/VTooltip.js.map +1 -1
- package/es5/components/VTreeview/VTreeview.js +0 -7
- package/es5/components/VTreeview/VTreeview.js.map +1 -1
- package/es5/framework.js +1 -1
- package/es5/mixins/routable/index.js +5 -2
- package/es5/mixins/routable/index.js.map +1 -1
- package/lib/components/VAlert/VAlert.js +0 -1
- package/lib/components/VAlert/VAlert.js.map +1 -1
- package/lib/components/VChip/VChip.js +1 -0
- package/lib/components/VChip/VChip.js.map +1 -1
- package/lib/components/VList/VListItem.js +4 -2
- package/lib/components/VList/VListItem.js.map +1 -1
- package/lib/components/VMenu/VMenu.js +1 -1
- package/lib/components/VMenu/VMenu.js.map +1 -1
- package/lib/components/VOtpInput/VOtpInput.js +48 -0
- package/lib/components/VOtpInput/VOtpInput.js.map +1 -1
- package/lib/components/VSelect/VSelectList.js +11 -5
- package/lib/components/VSelect/VSelectList.js.map +1 -1
- package/lib/components/VTooltip/VTooltip.js +3 -3
- package/lib/components/VTooltip/VTooltip.js.map +1 -1
- package/lib/components/VTreeview/VTreeview.js +0 -6
- package/lib/components/VTreeview/VTreeview.js.map +1 -1
- package/lib/framework.js +1 -1
- package/lib/mixins/routable/index.js +5 -2
- package/lib/mixins/routable/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VAlert/VAlert.ts +0 -1
- package/src/components/VApp/__tests__/VApp.spec.ts +24 -18
- package/src/components/VApp/__tests__/__snapshots__/VApp.spec.ts.snap +4 -4
- package/src/components/VAppBar/__tests__/VAppBar.spec.ts +256 -74
- package/src/components/VAppBar/__tests__/VAppBarNavIcon.spec.ts +2 -6
- package/src/components/VAppBar/__tests__/__snapshots__/VAppBar.spec.ts.snap +13 -4
- package/src/components/VAppBar/__tests__/__snapshots__/VAppBarNavIcon.spec.ts.snap +3 -4
- package/src/components/VBanner/__tests__/VBanner.spec.ts +35 -36
- package/src/components/VBanner/__tests__/__snapshots__/VBanner.spec.ts.snap +1 -1
- package/src/components/VBtn/__tests__/VBtn.spec.ts +1 -1
- package/src/components/VCard/__tests__/VCard.spec.ts +46 -28
- package/src/components/VCard/__tests__/__snapshots__/VCard.spec.ts.snap +2 -2
- package/src/components/VCheckbox/__tests__/VCheckbox.spec.ts +157 -152
- package/src/components/VChip/VChip.ts +1 -0
- package/src/components/VChip/__tests__/VChip.spec.ts +50 -50
- package/src/components/VChip/__tests__/__snapshots__/VChip.spec.ts.snap +4 -4
- package/src/components/VChipGroup/__tests__/VChipGroup.spec.ts +14 -21
- package/src/components/VColorPicker/__tests__/__snapshots__/VColorPicker.spec.ts.snap +35 -35
- package/src/components/VColorPicker/__tests__/__snapshots__/VColorPickerEdit.spec.ts.snap +10 -10
- package/src/components/VData/__tests__/VData.spec.ts +69 -90
- package/src/components/VDataTable/__tests__/MobileRow.spec.ts +55 -66
- package/src/components/VDataTable/__tests__/Row.spec.ts +64 -73
- package/src/components/VDataTable/__tests__/RowGroup.spec.ts +7 -5
- package/src/components/VDataTable/__tests__/VDataTable.spec.ts +910 -988
- package/src/components/VDataTable/__tests__/VEditDialog.spec.ts +26 -22
- package/src/components/VDataTable/__tests__/VSimpleTable.spec.ts +60 -29
- package/src/components/VDataTable/__tests__/VVirtualTable.spec.ts +13 -15
- package/src/components/VDataTable/__tests__/__snapshots__/Row.spec.ts.snap +30 -0
- package/src/components/VDataTable/__tests__/__snapshots__/VEditDialog.spec.ts.snap +18 -10
- package/src/components/VDataTable/mixins/__tests__/__snapshots__/header.spec.ts.snap +1 -1
- package/src/components/VDivider/__tests__/VDivider.spec.ts +11 -15
- package/src/components/VDivider/__tests__/__snapshots__/VDivider.spec.ts.snap +2 -2
- package/src/components/VGrid/__tests__/VCol.spec.ts +17 -17
- package/src/components/VGrid/__tests__/VContainer.spec.ts +58 -3
- package/src/components/VGrid/__tests__/VFlex.spec.ts +3 -3
- package/src/components/VGrid/__tests__/VGrid.spec.ts +12 -10
- package/src/components/VGrid/__tests__/VLayout.spec.ts +3 -3
- package/src/components/VIcon/__tests__/VIcon.spec.ts +176 -70
- package/src/components/VImg/__tests__/__snapshots__/VImg.spec.ts.snap +55 -55
- package/src/components/VItemGroup/__tests__/VItem.spec.ts +22 -37
- package/src/components/VItemGroup/__tests__/VItemGroup.spec.ts +96 -124
- package/src/components/VItemGroup/__tests__/__snapshots__/VItem.spec.ts.snap +2 -0
- package/src/components/VLabel/__tests__/VLabel.spec.ts +240 -14
- package/src/components/VLazy/__tests__/VLazy.spec.ts +5 -4
- package/src/components/VLazy/__tests__/__snapshots__/VLazy.spec.ts.snap +2 -1
- package/src/components/VList/VListItem.ts +9 -3
- package/src/components/VList/__tests__/VList.spec.ts +13 -12
- package/src/components/VList/__tests__/VListGroup.spec.ts +59 -51
- package/src/components/VList/__tests__/VListItem.spec.ts +142 -63
- package/src/components/VList/__tests__/VListItemAvatar.spec.ts +5 -2
- package/src/components/VList/__tests__/VListItemGroup.spec.ts +5 -2
- package/src/components/VList/__tests__/__snapshots__/VList.spec.ts.snap +10 -10
- package/src/components/VList/__tests__/__snapshots__/VListGroup.spec.ts.snap +5 -6
- package/src/components/VList/__tests__/__snapshots__/VListItem.spec.ts.snap +1 -1
- package/src/components/VMain/__tests__/VMain.spec.ts +71 -17
- package/src/components/VMenu/VMenu.ts +1 -1
- package/src/components/VMessages/__tests__/VMessages.spec.ts +14 -13
- package/src/components/VOtpInput/VOtpInput.ts +37 -1
- package/src/components/VParallax/__tests__/__snapshots__/VParallax.spec.ts.snap +8 -8
- package/src/components/VPicker/__tests__/__snapshots__/VPicker.spec.ts.snap +2 -2
- package/src/components/VResponsive/__tests__/__snapshots__/VResponsive.spec.ts.snap +2 -2
- package/src/components/VSelect/VSelectList.ts +9 -9
- package/src/components/VSelect/__tests__/VSelect.spec.ts +166 -125
- package/src/components/VSelect/__tests__/VSelect2.spec.ts +127 -111
- package/src/components/VSelect/__tests__/VSelect3.spec.ts +109 -91
- package/src/components/VSelect/__tests__/VSelect4.spec.ts +79 -68
- package/src/components/VSelect/__tests__/VSelectList.spec.ts +23 -31
- package/src/components/VSelect/__tests__/__snapshots__/VSelect.spec.ts.snap +58 -62
- package/src/components/VSelect/__tests__/__snapshots__/VSelect2.spec.ts.snap +50 -62
- package/src/components/VSelect/__tests__/__snapshots__/VSelect3.spec.ts.snap +10 -14
- package/src/components/VSparkline/__tests__/VSparkline.spec.ts +33 -35
- package/src/components/VStepper/__tests__/VStepper.spec.ts +4 -1
- package/src/components/VStepper/__tests__/VStepperContent.spec.ts +104 -110
- package/src/components/VStepper/__tests__/VStepperStep.spec.ts +51 -44
- package/src/components/VSwitch/__tests__/VSwitch.spec.ts +30 -37
- package/src/components/VTabs/__tests__/VTabs.spec.ts +0 -7
- package/src/components/VTextField/__tests__/VTextField.spec.ts +342 -246
- package/src/components/VTextarea/__tests__/VTextarea.spec.ts +112 -35
- package/src/components/VTimePicker/__tests__/__snapshots__/VTimePicker.spec.ts.snap +0 -40
- package/src/components/VToolbar/__tests__/VToolbar.spec.ts +49 -25
- package/src/components/VTooltip/VTooltip.ts +3 -3
- package/src/components/VTooltip/__tests__/__snapshots__/VTooltip.spec.ts.snap +34 -18
- package/src/components/VTreeview/VTreeview.ts +0 -5
- package/src/mixins/routable/index.ts +6 -4
|
@@ -4,13 +4,14 @@ import VSelect from '../VSelect'
|
|
|
4
4
|
// Utilities
|
|
5
5
|
import {
|
|
6
6
|
mount,
|
|
7
|
-
|
|
7
|
+
VueWrapper,
|
|
8
|
+
enableAutoUnmount,
|
|
8
9
|
} from '@vue/test-utils'
|
|
9
10
|
|
|
10
11
|
// eslint-disable-next-line max-statements
|
|
11
12
|
describe('VSelect.ts', () => {
|
|
12
13
|
type Instance = InstanceType<typeof VSelect>
|
|
13
|
-
let mountFunction: (options?: object) =>
|
|
14
|
+
let mountFunction: (options?: object) => VueWrapper<Instance>
|
|
14
15
|
let el
|
|
15
16
|
|
|
16
17
|
beforeEach(() => {
|
|
@@ -19,15 +20,18 @@ describe('VSelect.ts', () => {
|
|
|
19
20
|
document.body.appendChild(el)
|
|
20
21
|
mountFunction = (options = {}) => {
|
|
21
22
|
return mount(VSelect, {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
global: {
|
|
24
|
+
mocks: {
|
|
25
|
+
$vuetify: {
|
|
26
|
+
lang: {
|
|
27
|
+
t: (val: string) => val,
|
|
28
|
+
},
|
|
29
|
+
theme: {
|
|
30
|
+
dark: false,
|
|
31
|
+
},
|
|
32
|
+
icons: {
|
|
33
|
+
component: 'mdi',
|
|
34
|
+
},
|
|
31
35
|
},
|
|
32
36
|
},
|
|
33
37
|
},
|
|
@@ -40,38 +44,35 @@ describe('VSelect.ts', () => {
|
|
|
40
44
|
document.body.removeChild(el)
|
|
41
45
|
})
|
|
42
46
|
|
|
47
|
+
enableAutoUnmount(afterEach)
|
|
48
|
+
|
|
43
49
|
it('should select an item !multiple', async () => {
|
|
44
50
|
const wrapper = mountFunction()
|
|
45
51
|
|
|
46
|
-
const input = jest.fn()
|
|
47
|
-
const change = jest.fn()
|
|
48
|
-
wrapper.vm.$on('input', input)
|
|
49
|
-
wrapper.vm.$on('change', change)
|
|
50
|
-
|
|
51
52
|
wrapper.vm.selectItem('foo')
|
|
52
53
|
|
|
53
54
|
expect(wrapper.vm.internalValue).toBe('foo')
|
|
54
|
-
expect(
|
|
55
|
-
expect(
|
|
55
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(2)
|
|
56
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['foo'])
|
|
56
57
|
|
|
57
58
|
await wrapper.vm.$nextTick()
|
|
58
59
|
|
|
59
|
-
expect(
|
|
60
|
-
expect(change).
|
|
60
|
+
expect(wrapper.emitted('change')).toHaveLength(1)
|
|
61
|
+
expect(wrapper.emitted('change')?.[0]).toEqual(['foo'])
|
|
61
62
|
|
|
62
|
-
wrapper.setProps({ returnObject: true })
|
|
63
|
+
await wrapper.setProps({ returnObject: true })
|
|
63
64
|
|
|
64
65
|
const item = { foo: 'bar' }
|
|
65
66
|
wrapper.vm.selectItem(item)
|
|
66
67
|
|
|
67
|
-
expect(wrapper.vm.internalValue).
|
|
68
|
-
expect(
|
|
69
|
-
expect(
|
|
68
|
+
expect(wrapper.vm.internalValue).toStrictEqual(item)
|
|
69
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(4)
|
|
70
|
+
expect(wrapper.emitted('update:modelValue')?.[3]).toEqual([item])
|
|
70
71
|
|
|
71
72
|
await wrapper.vm.$nextTick()
|
|
72
73
|
|
|
73
|
-
expect(change).
|
|
74
|
-
expect(change).
|
|
74
|
+
expect(wrapper.emitted('change')).toHaveLength(2)
|
|
75
|
+
expect(wrapper.emitted('change')?.[1]).toEqual([item])
|
|
75
76
|
})
|
|
76
77
|
|
|
77
78
|
// TODO: this fails without sync, nextTick doesn't help
|
|
@@ -79,7 +80,7 @@ describe('VSelect.ts', () => {
|
|
|
79
80
|
it.skip('should disable v-list-item', async () => {
|
|
80
81
|
const selectItem = jest.fn()
|
|
81
82
|
const wrapper = mountFunction({
|
|
82
|
-
|
|
83
|
+
props: {
|
|
83
84
|
eager: true,
|
|
84
85
|
items: [{ text: 'foo', disabled: true, id: 0 }],
|
|
85
86
|
},
|
|
@@ -107,10 +108,8 @@ describe('VSelect.ts', () => {
|
|
|
107
108
|
const wrapper = mountFunction()
|
|
108
109
|
const menu = wrapper.vm.$refs.menu
|
|
109
110
|
|
|
110
|
-
wrapper.
|
|
111
|
-
|
|
112
|
-
isFocused: true,
|
|
113
|
-
})
|
|
111
|
+
wrapper.vm.isMenuActive = true
|
|
112
|
+
wrapper.vm.isFocused = true
|
|
114
113
|
|
|
115
114
|
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
116
115
|
expect(wrapper.vm.isFocused).toBe(true)
|
|
@@ -119,9 +118,12 @@ describe('VSelect.ts', () => {
|
|
|
119
118
|
|
|
120
119
|
expect(menu.isActive).toBe(true)
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
// В Vue 3 нужно использовать правильный способ закрытия меню
|
|
122
|
+
wrapper.vm.isMenuActive = false
|
|
123
|
+
wrapper.vm.isFocused = false // Сбрасываем фокус вручную
|
|
123
124
|
|
|
124
125
|
await wrapper.vm.$nextTick()
|
|
126
|
+
await wrapper.vm.$nextTick() // Дополнительная задержка для Vue 3
|
|
125
127
|
|
|
126
128
|
expect(wrapper.vm.isMenuActive).toBe(false)
|
|
127
129
|
expect(wrapper.vm.isFocused).toBe(false)
|
|
@@ -132,31 +134,25 @@ describe('VSelect.ts', () => {
|
|
|
132
134
|
it.skip('should update model when chips are removed', async () => {
|
|
133
135
|
const selectItem = jest.fn()
|
|
134
136
|
const wrapper = mountFunction({
|
|
135
|
-
|
|
137
|
+
props: {
|
|
136
138
|
chips: true,
|
|
137
139
|
deletableChips: true,
|
|
138
140
|
items: ['foo'],
|
|
139
|
-
|
|
141
|
+
modelValue: 'foo',
|
|
140
142
|
},
|
|
141
143
|
methods: { selectItem },
|
|
142
144
|
})
|
|
143
145
|
|
|
144
|
-
const input = jest.fn()
|
|
145
|
-
const change = jest.fn()
|
|
146
|
-
|
|
147
|
-
wrapper.vm.$on('input', input)
|
|
148
|
-
|
|
149
146
|
expect(wrapper.vm.internalValue).toEqual('foo')
|
|
150
147
|
wrapper.find('.v-chip__close').trigger('click')
|
|
151
148
|
|
|
152
|
-
expect(
|
|
149
|
+
expect(wrapper.emitted('update:modelValue')).toHaveLength(1)
|
|
153
150
|
|
|
154
|
-
wrapper.setProps({
|
|
151
|
+
await wrapper.setProps({
|
|
155
152
|
items: ['foo', 'bar'],
|
|
156
153
|
multiple: true,
|
|
157
|
-
|
|
154
|
+
modelValue: ['foo', 'bar'],
|
|
158
155
|
})
|
|
159
|
-
wrapper.vm.$on('change', change)
|
|
160
156
|
await wrapper.vm.$nextTick()
|
|
161
157
|
|
|
162
158
|
expect(wrapper.vm.internalValue).toEqual(['foo', 'bar'])
|
|
@@ -171,12 +167,12 @@ describe('VSelect.ts', () => {
|
|
|
171
167
|
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
172
168
|
it.skip('should set selected index', async () => {
|
|
173
169
|
const wrapper = mountFunction({
|
|
174
|
-
|
|
170
|
+
props: {
|
|
175
171
|
chips: true,
|
|
176
172
|
deletableChips: true,
|
|
177
173
|
multiple: true,
|
|
178
174
|
items: ['foo', 'bar', 'fizz', 'buzz'],
|
|
179
|
-
|
|
175
|
+
modelValue: ['foo', 'bar', 'fizz', 'buzz'],
|
|
180
176
|
},
|
|
181
177
|
})
|
|
182
178
|
|
|
@@ -187,7 +183,7 @@ describe('VSelect.ts', () => {
|
|
|
187
183
|
|
|
188
184
|
expect(wrapper.vm.selectedIndex).toBe(0)
|
|
189
185
|
|
|
190
|
-
wrapper.findAll('.v-chip')
|
|
186
|
+
wrapper.findAll('.v-chip')[1].trigger('click')
|
|
191
187
|
|
|
192
188
|
expect(wrapper.vm.selectedIndex).toBe(1)
|
|
193
189
|
|
|
@@ -200,7 +196,7 @@ describe('VSelect.ts', () => {
|
|
|
200
196
|
|
|
201
197
|
it('should not duplicate items after items update when caching is turned on', async () => {
|
|
202
198
|
const wrapper = mountFunction({
|
|
203
|
-
|
|
199
|
+
props: {
|
|
204
200
|
cacheItems: true,
|
|
205
201
|
returnObject: true,
|
|
206
202
|
itemText: 'text',
|
|
@@ -209,9 +205,9 @@ describe('VSelect.ts', () => {
|
|
|
209
205
|
},
|
|
210
206
|
})
|
|
211
207
|
|
|
212
|
-
wrapper.setProps({ items: [{ id: 1, text: 'A' }] })
|
|
208
|
+
await wrapper.setProps({ items: [{ id: 1, text: 'A' }] })
|
|
213
209
|
expect(wrapper.vm.computedItems).toHaveLength(1)
|
|
214
|
-
wrapper.setProps({ items: [{ id: 1, text: 'A' }] })
|
|
210
|
+
await wrapper.setProps({ items: [{ id: 1, text: 'A' }] })
|
|
215
211
|
expect(wrapper.vm.computedItems).toHaveLength(1)
|
|
216
212
|
})
|
|
217
213
|
|
|
@@ -219,28 +215,28 @@ describe('VSelect.ts', () => {
|
|
|
219
215
|
// https://github.com/vuejs/vue-test-utils/issues/1130
|
|
220
216
|
it.skip('should cache items', async () => {
|
|
221
217
|
const wrapper = mountFunction({
|
|
222
|
-
|
|
218
|
+
props: {
|
|
223
219
|
cacheItems: true,
|
|
224
220
|
items: [],
|
|
225
221
|
},
|
|
226
222
|
})
|
|
227
223
|
|
|
228
|
-
wrapper.setProps({ items: ['bar', 'baz'] })
|
|
224
|
+
await wrapper.setProps({ items: ['bar', 'baz'] })
|
|
229
225
|
await wrapper.vm.$nextTick()
|
|
230
226
|
expect(wrapper.vm.computedItems).toHaveLength(2)
|
|
231
227
|
|
|
232
|
-
wrapper.setProps({ items: ['foo'] })
|
|
228
|
+
await wrapper.setProps({ items: ['foo'] })
|
|
233
229
|
await wrapper.vm.$nextTick()
|
|
234
230
|
expect(wrapper.vm.computedItems).toHaveLength(3)
|
|
235
231
|
|
|
236
|
-
wrapper.setProps({ items: ['bar'] })
|
|
232
|
+
await wrapper.setProps({ items: ['bar'] })
|
|
237
233
|
await wrapper.vm.$nextTick()
|
|
238
234
|
expect(wrapper.vm.computedItems).toHaveLength(3)
|
|
239
235
|
})
|
|
240
236
|
|
|
241
237
|
it('should cache items passed via prop', async () => {
|
|
242
238
|
const wrapper = mountFunction({
|
|
243
|
-
|
|
239
|
+
props: {
|
|
244
240
|
cacheItems: true,
|
|
245
241
|
items: [1, 2, 3, 4],
|
|
246
242
|
},
|
|
@@ -249,12 +245,13 @@ describe('VSelect.ts', () => {
|
|
|
249
245
|
expect(wrapper.vm.computedItems).toHaveLength(4)
|
|
250
246
|
|
|
251
247
|
wrapper.setProps({ items: [5] })
|
|
248
|
+
await wrapper.vm.$nextTick()
|
|
252
249
|
expect(wrapper.vm.computedItems).toHaveLength(5)
|
|
253
250
|
})
|
|
254
251
|
|
|
255
252
|
it('should have an affix', async () => {
|
|
256
253
|
const wrapper = mountFunction({
|
|
257
|
-
|
|
254
|
+
props: {
|
|
258
255
|
prefix: '$',
|
|
259
256
|
suffix: 'lbs',
|
|
260
257
|
},
|
|
@@ -274,29 +271,30 @@ describe('VSelect.ts', () => {
|
|
|
274
271
|
it('should use custom clear icon cb', async () => {
|
|
275
272
|
const clearIconCb = jest.fn()
|
|
276
273
|
const wrapper = mountFunction({
|
|
277
|
-
|
|
274
|
+
props: {
|
|
278
275
|
clearable: true,
|
|
279
276
|
items: ['foo'],
|
|
280
|
-
|
|
277
|
+
modelValue: 'foo',
|
|
281
278
|
},
|
|
282
279
|
})
|
|
283
280
|
|
|
284
|
-
|
|
281
|
+
// В Vue 3 события тестируются через emitted()
|
|
285
282
|
wrapper.find('.v-input__icon--clear .v-icon').trigger('click')
|
|
286
283
|
|
|
287
|
-
|
|
284
|
+
// Проверяем, что событие click:clear было эмитировано
|
|
285
|
+
expect(wrapper.emitted('click:clear')).toBeTruthy()
|
|
288
286
|
})
|
|
289
287
|
|
|
290
288
|
it('should populate select[multiple=false] when using value as an object', async () => {
|
|
291
289
|
const wrapper = mountFunction({
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
attachTo: document.body,
|
|
291
|
+
props: {
|
|
294
292
|
items: [
|
|
295
293
|
{ text: 'foo', value: { id: { subid: 1 } } },
|
|
296
294
|
{ text: 'foo', value: { id: { subid: 2 } } },
|
|
297
295
|
],
|
|
298
296
|
multiple: false,
|
|
299
|
-
|
|
297
|
+
modelValue: { id: { subid: 2 } },
|
|
300
298
|
},
|
|
301
299
|
})
|
|
302
300
|
|
|
@@ -307,10 +305,10 @@ describe('VSelect.ts', () => {
|
|
|
307
305
|
|
|
308
306
|
it('should add color to selected index', async () => {
|
|
309
307
|
const wrapper = mountFunction({
|
|
310
|
-
|
|
308
|
+
props: {
|
|
311
309
|
multiple: true,
|
|
312
310
|
items: ['foo', 'bar'],
|
|
313
|
-
|
|
311
|
+
modelValue: ['foo'],
|
|
314
312
|
},
|
|
315
313
|
})
|
|
316
314
|
|
|
@@ -323,7 +321,7 @@ describe('VSelect.ts', () => {
|
|
|
323
321
|
|
|
324
322
|
it('should not react to click when disabled', async () => {
|
|
325
323
|
const wrapper = mountFunction({
|
|
326
|
-
|
|
324
|
+
props: { items: ['foo', 'bar'] },
|
|
327
325
|
})
|
|
328
326
|
|
|
329
327
|
const slot = wrapper.find('.v-input__slot')
|
|
@@ -332,7 +330,7 @@ describe('VSelect.ts', () => {
|
|
|
332
330
|
slot.trigger('click')
|
|
333
331
|
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
334
332
|
|
|
335
|
-
wrapper.
|
|
333
|
+
wrapper.vm.isMenuActive = false
|
|
336
334
|
wrapper.setProps({ disabled: true })
|
|
337
335
|
|
|
338
336
|
await wrapper.vm.$nextTick()
|
|
@@ -356,61 +354,77 @@ describe('VSelect.ts', () => {
|
|
|
356
354
|
// Inspired by https://github.com/vuetifyjs/vuetify/pull/1425 - Thanks @kevmo314
|
|
357
355
|
it('should open the select when enter is pressed', async () => {
|
|
358
356
|
const wrapper = mountFunction({
|
|
359
|
-
|
|
357
|
+
props: {
|
|
360
358
|
items: ['foo', 'bar'],
|
|
361
359
|
},
|
|
362
360
|
})
|
|
363
361
|
|
|
364
|
-
wrapper.find('input')
|
|
362
|
+
const input = wrapper.find('input')
|
|
363
|
+
input.trigger('focus')
|
|
365
364
|
await wrapper.vm.$nextTick()
|
|
365
|
+
expect(wrapper.vm.isMenuActive).toBe(false)
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
input.trigger('keydown.enter')
|
|
368
|
+
await wrapper.vm.$nextTick()
|
|
369
|
+
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
368
370
|
})
|
|
369
371
|
|
|
370
372
|
it('should open the select when space is pressed', async () => {
|
|
371
373
|
const wrapper = mountFunction({
|
|
372
|
-
|
|
374
|
+
props: {
|
|
373
375
|
items: ['foo', 'bar'],
|
|
374
376
|
},
|
|
375
377
|
})
|
|
376
378
|
|
|
377
|
-
wrapper.find('input')
|
|
379
|
+
const input = wrapper.find('input')
|
|
380
|
+
input.trigger('focus')
|
|
378
381
|
await wrapper.vm.$nextTick()
|
|
382
|
+
expect(wrapper.vm.isMenuActive).toBe(false)
|
|
379
383
|
|
|
380
|
-
|
|
384
|
+
input.trigger('keydown.space')
|
|
385
|
+
await wrapper.vm.$nextTick()
|
|
386
|
+
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
381
387
|
})
|
|
382
388
|
|
|
383
389
|
it('should open the select is multiple and key up is pressed', async () => {
|
|
384
390
|
const wrapper = mountFunction({
|
|
385
|
-
|
|
391
|
+
props: {
|
|
386
392
|
multiple: true,
|
|
387
393
|
items: ['foo', 'bar'],
|
|
388
394
|
},
|
|
389
395
|
})
|
|
390
396
|
|
|
391
|
-
wrapper.find('input')
|
|
397
|
+
const input = wrapper.find('input')
|
|
398
|
+
input.trigger('focus')
|
|
392
399
|
await wrapper.vm.$nextTick()
|
|
400
|
+
expect(wrapper.vm.isMenuActive).toBe(false)
|
|
393
401
|
|
|
394
|
-
|
|
402
|
+
input.trigger('keydown.up')
|
|
403
|
+
await wrapper.vm.$nextTick()
|
|
404
|
+
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
395
405
|
})
|
|
396
406
|
|
|
397
407
|
it('should open the select is multiple and key down is pressed', async () => {
|
|
398
408
|
const wrapper = mountFunction({
|
|
399
|
-
|
|
409
|
+
props: {
|
|
400
410
|
multiple: true,
|
|
401
411
|
items: ['foo', 'bar'],
|
|
402
412
|
},
|
|
403
413
|
})
|
|
404
414
|
|
|
405
|
-
wrapper.find('input')
|
|
415
|
+
const input = wrapper.find('input')
|
|
416
|
+
input.trigger('focus')
|
|
406
417
|
await wrapper.vm.$nextTick()
|
|
418
|
+
expect(wrapper.vm.isMenuActive).toBe(false)
|
|
407
419
|
|
|
408
|
-
|
|
420
|
+
input.trigger('keydown.down')
|
|
421
|
+
await wrapper.vm.$nextTick()
|
|
422
|
+
expect(wrapper.vm.isMenuActive).toBe(true)
|
|
409
423
|
})
|
|
410
424
|
|
|
411
425
|
it('should return full items if using auto prop', async () => {
|
|
412
426
|
const wrapper = mountFunction({
|
|
413
|
-
|
|
427
|
+
props: {
|
|
414
428
|
items: [...Array(100).keys()],
|
|
415
429
|
},
|
|
416
430
|
})
|
|
@@ -418,13 +432,14 @@ describe('VSelect.ts', () => {
|
|
|
418
432
|
expect(wrapper.vm.virtualizedItems).toHaveLength(20)
|
|
419
433
|
|
|
420
434
|
wrapper.setProps({ menuProps: 'auto' })
|
|
435
|
+
await wrapper.vm.$nextTick()
|
|
421
436
|
|
|
422
437
|
expect(wrapper.vm.virtualizedItems).toHaveLength(100)
|
|
423
438
|
})
|
|
424
439
|
|
|
425
440
|
it('should fallback to using text as value if none present', async () => {
|
|
426
441
|
const wrapper = mountFunction({
|
|
427
|
-
|
|
442
|
+
props: {
|
|
428
443
|
items: [{
|
|
429
444
|
text: 'foo',
|
|
430
445
|
}],
|
|
@@ -436,21 +451,24 @@ describe('VSelect.ts', () => {
|
|
|
436
451
|
|
|
437
452
|
it('should accept arrays as values', async () => {
|
|
438
453
|
const wrapper = mountFunction({
|
|
439
|
-
|
|
454
|
+
props: {
|
|
440
455
|
items: [
|
|
441
456
|
{ text: 'Foo', value: ['bar'] },
|
|
442
457
|
],
|
|
443
458
|
},
|
|
444
459
|
})
|
|
445
460
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
wrapper.vm.selectItem(wrapper.vm.items[0])
|
|
461
|
+
expect(wrapper.vm.items).toEqual([
|
|
462
|
+
{ text: 'Foo', value: ['bar'] },
|
|
463
|
+
])
|
|
450
464
|
|
|
465
|
+
// Тестируем выбор элемента
|
|
466
|
+
wrapper.vm.selectItem({ text: 'Foo', value: ['bar'] })
|
|
451
467
|
await wrapper.vm.$nextTick()
|
|
452
468
|
|
|
453
|
-
|
|
469
|
+
const emitted = wrapper.emitted('update:modelValue')
|
|
470
|
+
expect(emitted).toBeTruthy()
|
|
471
|
+
expect(emitted[emitted.length - 1]).toEqual([['bar']])
|
|
454
472
|
expect(wrapper.vm.selectedItems).toEqual([
|
|
455
473
|
{ text: 'Foo', value: ['bar'] },
|
|
456
474
|
])
|
|
@@ -458,14 +476,14 @@ describe('VSelect.ts', () => {
|
|
|
458
476
|
|
|
459
477
|
it('should update inner input element', async () => {
|
|
460
478
|
const wrapper = mountFunction({
|
|
461
|
-
|
|
479
|
+
props: {
|
|
462
480
|
items: ['foo', 'bar', 'fizz', 'buzz'],
|
|
463
|
-
|
|
481
|
+
modelValue: ['fizz'],
|
|
464
482
|
},
|
|
465
483
|
})
|
|
466
484
|
|
|
467
485
|
const inputs = wrapper.findAll('input')
|
|
468
|
-
const element = inputs
|
|
486
|
+
const element = inputs[1].element
|
|
469
487
|
|
|
470
488
|
expect(element.value).toEqual('fizz')
|
|
471
489
|
|
|
@@ -478,14 +496,14 @@ describe('VSelect.ts', () => {
|
|
|
478
496
|
|
|
479
497
|
it('should pass the name attribute to the inner input element', async () => {
|
|
480
498
|
const wrapper = mountFunction({
|
|
481
|
-
|
|
499
|
+
props: {
|
|
482
500
|
items: ['foo'],
|
|
483
501
|
name: ['bar'],
|
|
484
502
|
},
|
|
485
503
|
})
|
|
486
504
|
|
|
487
505
|
const inputs = wrapper.findAll('input')
|
|
488
|
-
const element = inputs
|
|
506
|
+
const element = inputs[1].element
|
|
489
507
|
|
|
490
508
|
expect(element.name).toEqual('bar')
|
|
491
509
|
})
|