@dimailn/vuetify 2.7.2-alpha24 → 2.7.2-alpha25

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.
Files changed (74) hide show
  1. package/dist/vuetify.js +241 -230
  2. package/dist/vuetify.js.map +1 -1
  3. package/dist/vuetify.min.css +1 -1
  4. package/dist/vuetify.min.js +2 -2
  5. package/es5/components/VBtn/VBtn.js +16 -16
  6. package/es5/components/VBtn/VBtn.js.map +1 -1
  7. package/es5/components/VColorPicker/VColorPicker.js +18 -31
  8. package/es5/components/VColorPicker/VColorPicker.js.map +1 -1
  9. package/es5/components/VColorPicker/VColorPickerCanvas.js +45 -46
  10. package/es5/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  11. package/es5/components/VColorPicker/VColorPickerEdit.js +27 -26
  12. package/es5/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  13. package/es5/components/VColorPicker/VColorPickerPreview.js +41 -30
  14. package/es5/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  15. package/es5/components/VColorPicker/VColorPickerSwatches.js +13 -10
  16. package/es5/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  17. package/es5/components/VDataTable/VDataTable.js +7 -11
  18. package/es5/components/VDataTable/VDataTable.js.map +1 -1
  19. package/es5/components/VInput/VInput.js +20 -6
  20. package/es5/components/VInput/VInput.js.map +1 -1
  21. package/es5/components/VSlider/VSlider.js +23 -18
  22. package/es5/components/VSlider/VSlider.js.map +1 -1
  23. package/es5/components/VTooltip/VTooltip.js +3 -7
  24. package/es5/components/VTooltip/VTooltip.js.map +1 -1
  25. package/es5/framework.js +1 -1
  26. package/lib/components/VBtn/VBtn.js +18 -19
  27. package/lib/components/VBtn/VBtn.js.map +1 -1
  28. package/lib/components/VColorPicker/VColorPicker.js +29 -37
  29. package/lib/components/VColorPicker/VColorPicker.js.map +1 -1
  30. package/lib/components/VColorPicker/VColorPickerCanvas.js +41 -43
  31. package/lib/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  32. package/lib/components/VColorPicker/VColorPickerEdit.js +25 -31
  33. package/lib/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  34. package/lib/components/VColorPicker/VColorPickerPreview.js +45 -32
  35. package/lib/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  36. package/lib/components/VColorPicker/VColorPickerSwatches.js +15 -9
  37. package/lib/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  38. package/lib/components/VDataTable/VDataTable.js +3 -4
  39. package/lib/components/VDataTable/VDataTable.js.map +1 -1
  40. package/lib/components/VInput/VInput.js +12 -4
  41. package/lib/components/VInput/VInput.js.map +1 -1
  42. package/lib/components/VSlider/VSlider.js +26 -21
  43. package/lib/components/VSlider/VSlider.js.map +1 -1
  44. package/lib/components/VTooltip/VTooltip.js +6 -9
  45. package/lib/components/VTooltip/VTooltip.js.map +1 -1
  46. package/lib/framework.js +1 -1
  47. package/package.json +1 -1
  48. package/src/components/VBtn/VBtn.ts +18 -16
  49. package/src/components/VBtn/__tests__/VBtn.spec.ts +257 -242
  50. package/src/components/VBtn/__tests__/__snapshots__/VBtn.spec.ts.snap +13 -73
  51. package/src/components/VColorPicker/VColorPicker.ts +32 -35
  52. package/src/components/VColorPicker/VColorPickerCanvas.ts +44 -37
  53. package/src/components/VColorPicker/VColorPickerEdit.ts +37 -35
  54. package/src/components/VColorPicker/VColorPickerPreview.ts +48 -28
  55. package/src/components/VColorPicker/VColorPickerSwatches.ts +23 -12
  56. package/src/components/VColorPicker/__tests__/VColorPicker.spec.ts +47 -47
  57. package/src/components/VColorPicker/__tests__/VColorPickerCanvas.spec.ts +15 -13
  58. package/src/components/VColorPicker/__tests__/VColorPickerEdit.spec.ts +52 -50
  59. package/src/components/VColorPicker/__tests__/VColorPickerPreview.spec.ts +101 -30
  60. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPicker.spec.ts.snap +200 -157
  61. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPickerEdit.spec.ts.snap +28 -11
  62. package/src/components/VDataTable/VDataTable.ts +3 -3
  63. package/src/components/VInput/VInput.ts +8 -2
  64. package/src/components/VInput/__tests__/VInput.spec.ts +170 -234
  65. package/src/components/VInput/__tests__/__snapshots__/VInput.spec.ts.snap +50 -101
  66. package/src/components/VSkeletonLoader/__tests__/VSkeletonLoader.spec.ts +22 -15
  67. package/src/components/VSkeletonLoader/__tests__/__snapshots__/VSkeletonLoader.spec.ts.snap +60 -60
  68. package/src/components/VSlider/VSlider.ts +43 -27
  69. package/src/components/VSlider/__tests__/VSlider.spec.ts +188 -286
  70. package/src/components/VSlider/__tests__/__snapshots__/VSlider.spec.ts.snap +157 -246
  71. package/src/components/VTabs/__tests__/VTab.spec.ts +3 -3
  72. package/src/components/VTabs/__tests__/VTabsBar.spec.ts +2 -2
  73. package/src/components/VTooltip/VTooltip.ts +20 -20
  74. package/src/components/VTooltip/__tests__/VTooltip.spec.ts +60 -75
@@ -4,14 +4,15 @@ import VSlider from '../VSlider'
4
4
  // Utilities
5
5
  import {
6
6
  mount,
7
- Wrapper,
7
+ VueWrapper,
8
+ enableAutoUnmount,
8
9
  } from '@vue/test-utils'
9
10
 
10
11
  /* eslint-disable max-statements */
11
12
  describe('VSlider.ts', () => {
12
13
  type Instance = InstanceType<typeof VSlider>
13
- let mountFunction: (options?: object) => Wrapper<Instance>
14
- let el
14
+ let mountFunction: (options?: object) => VueWrapper<Instance>
15
+ let el: HTMLElement
15
16
 
16
17
  beforeEach(() => {
17
18
  el = document.createElement('div')
@@ -19,11 +20,11 @@ describe('VSlider.ts', () => {
19
20
  document.body.appendChild(el)
20
21
  mountFunction = (options = {}) => {
21
22
  return mount(VSlider, {
22
- // https://github.com/vuejs/vue-test-utils/issues/1130
23
- sync: false,
24
- mocks: {
25
- $vuetify: {
26
- rtl: false,
23
+ global: {
24
+ mocks: {
25
+ $vuetify: {
26
+ rtl: false,
27
+ },
27
28
  },
28
29
  },
29
30
  ...options,
@@ -31,9 +32,8 @@ describe('VSlider.ts', () => {
31
32
  }
32
33
  })
33
34
 
34
- afterEach(() => {
35
- document.body.removeChild(el)
36
- })
35
+ // Включаем автоматическое размонтирование компонентов после каждого теста
36
+ enableAutoUnmount(afterEach)
37
37
 
38
38
  it('should match a snapshot', () => {
39
39
  const wrapper = mountFunction()
@@ -43,7 +43,7 @@ describe('VSlider.ts', () => {
43
43
 
44
44
  it('should render vertical slider', async () => {
45
45
  const wrapper = mountFunction({
46
- propsData: {
46
+ props: {
47
47
  vertical: true,
48
48
  },
49
49
  })
@@ -53,48 +53,36 @@ describe('VSlider.ts', () => {
53
53
 
54
54
  it('should render component with ticks and match a snapshot', async () => {
55
55
  const wrapper = mountFunction({
56
- propsData: {
57
- ticks: 'yes',
56
+ props: {
57
+ ticks: true,
58
58
  step: 25,
59
59
  },
60
60
  })
61
61
 
62
- expect('Invalid prop: custom validator check failed for prop "ticks"').toHaveBeenWarned()
63
-
64
- wrapper.setProps({ ticks: true })
65
- await wrapper.vm.$nextTick()
66
-
67
62
  expect(wrapper.html()).toMatchSnapshot()
68
63
 
69
- wrapper.setProps({ ticks: 'always' })
70
- await wrapper.vm.$nextTick()
64
+ await wrapper.setProps({ ticks: 'always' })
71
65
 
72
66
  expect(wrapper.html()).toMatchSnapshot()
73
67
  })
74
68
 
75
69
  it('should render component with thumbLabel and match a snapshot', async () => {
76
70
  const wrapper = mountFunction({
77
- propsData: {
78
- thumbLabel: 'true',
71
+ props: {
72
+ thumbLabel: true,
79
73
  },
80
74
  })
81
75
 
82
- expect('Invalid prop: custom validator check failed for prop "thumbLabel"').toHaveBeenWarned()
83
-
84
- wrapper.setProps({ thumbLabel: true })
85
- await wrapper.vm.$nextTick()
86
-
87
76
  expect(wrapper.html()).toMatchSnapshot()
88
77
 
89
- wrapper.setProps({ thumbLabel: 'always' })
90
- await wrapper.vm.$nextTick()
78
+ await wrapper.setProps({ thumbLabel: 'always' })
91
79
 
92
80
  expect(wrapper.html()).toMatchSnapshot()
93
81
  })
94
82
 
95
83
  it('should set tabindex in disabled component', () => {
96
84
  const wrapper = mountFunction({
97
- propsData: {
85
+ props: {
98
86
  disabled: true,
99
87
  },
100
88
  })
@@ -106,293 +94,269 @@ describe('VSlider.ts', () => {
106
94
 
107
95
  it('should not allow values outside of min/max', async () => {
108
96
  const wrapper = mountFunction({
109
- propsData: {
97
+ props: {
110
98
  min: 2,
111
99
  max: 4,
112
100
  },
113
101
  })
114
102
 
115
- const input = jest.fn()
116
- wrapper.vm.$on('input', input)
117
-
118
- wrapper.setProps({ value: 0 })
119
- await wrapper.vm.$nextTick()
120
- expect(input).toHaveBeenCalledWith(2)
103
+ await wrapper.setProps({ modelValue: 0 })
104
+ const events1 = wrapper.emitted('update:modelValue') as any[][]
105
+ expect(events1[events1.length - 1]).toEqual([2])
121
106
 
122
- wrapper.setProps({ value: 5 })
123
- await wrapper.vm.$nextTick()
124
- expect(input).toHaveBeenCalledWith(4)
107
+ await wrapper.setProps({ modelValue: 5 })
108
+ const events2 = wrapper.emitted('update:modelValue') as any[][]
109
+ expect(events2[events2.length - 1]).toEqual([4])
125
110
  })
126
111
 
127
112
  it('should adjust value if min/max props change', async () => {
128
113
  const wrapper = mountFunction({
129
- propsData: {
130
- value: 5,
114
+ props: {
115
+ modelValue: 5,
131
116
  min: 0,
132
117
  max: 10,
133
118
  },
134
119
  })
135
120
 
136
- const input = jest.fn()
137
- wrapper.vm.$on('input', input)
138
-
139
- wrapper.setProps({ min: 6 })
140
- await wrapper.vm.$nextTick()
141
- expect(input).toHaveBeenCalledWith(6)
121
+ await wrapper.setProps({ min: 6 })
122
+ expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([6])
142
123
 
143
- wrapper.setProps({ max: 4 })
144
- await wrapper.vm.$nextTick()
145
- expect(input).toHaveBeenCalledWith(4)
124
+ await wrapper.setProps({ max: 4 })
125
+ expect(wrapper.emitted('update:modelValue')?.[1]).toEqual([4])
146
126
  })
147
127
 
148
128
  it('should round value with offset correct', async () => {
149
129
  const wrapper = mountFunction({
150
- propsData: {
130
+ props: {
151
131
  min: 3,
152
132
  max: 15,
153
133
  step: 3,
154
134
  },
155
135
  })
156
136
 
157
- const input = jest.fn()
158
- wrapper.vm.$on('input', input)
159
-
160
- wrapper.setProps({ value: 5 })
161
- await wrapper.vm.$nextTick()
162
- expect(input).toHaveBeenLastCalledWith(6)
137
+ await wrapper.setProps({ modelValue: 5 })
138
+ const events1 = wrapper.emitted('update:modelValue') as any[][]
139
+ expect(events1[events1.length - 1]).toEqual([6])
163
140
 
164
- wrapper.setProps({ value: 7 })
165
- await wrapper.vm.$nextTick()
166
- expect(input).toHaveBeenLastCalledWith(6)
141
+ await wrapper.setProps({ modelValue: 7 })
142
+ const events2 = wrapper.emitted('update:modelValue') as any[][]
143
+ expect(events2[events2.length - 1]).toEqual([6])
167
144
  })
168
145
 
169
146
  it('should react to keydown event', async () => {
170
147
  const wrapper = mountFunction({
171
- propsData: {
172
- value: 50,
148
+ props: {
149
+ modelValue: 50,
173
150
  },
174
151
  })
175
152
 
176
- const input = jest.fn()
177
- wrapper.vm.$on('input', input)
178
-
179
153
  const slider = wrapper.find('.v-slider__thumb-container')
180
154
 
181
- slider.trigger('keydown.space')
182
- expect(input).not.toHaveBeenCalled()
183
- slider.trigger('keydown.left')
184
- expect(input).toHaveBeenCalledWith(49)
185
- slider.trigger('keydown.right')
186
- expect(input).toHaveBeenCalledWith(50)
187
- slider.trigger('keydown.home')
188
- expect(input).toHaveBeenCalledWith(0)
189
- slider.trigger('keydown.left')
190
- slider.trigger('keydown.end')
191
- expect(input).toHaveBeenCalledWith(100)
192
- slider.trigger('keydown.pagedown')
193
- expect(input).toHaveBeenCalledWith(90)
194
- slider.trigger('keydown.pageup')
195
- expect(input).toHaveBeenCalledWith(100)
196
-
197
- wrapper.setProps({ step: 4 })
198
- slider.trigger('keydown.pagedown')
199
- expect(input).toHaveBeenCalledWith(60)
200
- wrapper.setProps({ step: 2 })
201
- slider.trigger('keydown.pageup')
202
- expect(input).toHaveBeenCalledWith(80)
203
- wrapper.setProps({ max: 1000 })
204
- slider.trigger('keydown.pageup')
205
- expect(input).toHaveBeenCalledWith(180)
206
- slider.trigger('keydown.pagedown')
207
- wrapper.setProps({ max: 100 })
208
-
209
- slider.trigger('keydown.left', {
155
+ await slider.trigger('keydown.space')
156
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
157
+
158
+ await slider.trigger('keydown.left')
159
+ const events1 = wrapper.emitted('update:modelValue') as any[][]
160
+ expect(events1[events1.length - 1]).toEqual([49])
161
+
162
+ await slider.trigger('keydown.right')
163
+ const events2 = wrapper.emitted('update:modelValue') as any[][]
164
+ expect(events2[events2.length - 1]).toEqual([50])
165
+
166
+ await slider.trigger('keydown.home')
167
+ const events3 = wrapper.emitted('update:modelValue') as any[][]
168
+ expect(events3[events3.length - 1]).toEqual([0])
169
+
170
+ await slider.trigger('keydown.end')
171
+ const events4 = wrapper.emitted('update:modelValue') as any[][]
172
+ expect(events4[events4.length - 1]).toEqual([100])
173
+
174
+ await slider.trigger('keydown.pagedown')
175
+ const events5 = wrapper.emitted('update:modelValue') as any[][]
176
+ expect(events5[events5.length - 1]).toEqual([90])
177
+
178
+ await slider.trigger('keydown.pageup')
179
+ const events6 = wrapper.emitted('update:modelValue') as any[][]
180
+ expect(events6[events6.length - 1]).toEqual([100])
181
+
182
+ await wrapper.setProps({ step: 4 })
183
+ await slider.trigger('keydown.pagedown')
184
+ const events7 = wrapper.emitted('update:modelValue') as any[][]
185
+ expect(events7[events7.length - 1]).toEqual([60])
186
+
187
+ await wrapper.setProps({ step: 2 })
188
+ await slider.trigger('keydown.pageup')
189
+ const events8 = wrapper.emitted('update:modelValue') as any[][]
190
+ expect(events8[events8.length - 1]).toEqual([80])
191
+
192
+ await wrapper.setProps({ max: 1000 })
193
+ await slider.trigger('keydown.pageup')
194
+ const events9 = wrapper.emitted('update:modelValue') as any[][]
195
+ expect(events9[events9.length - 1]).toEqual([180])
196
+
197
+ await wrapper.setProps({ max: 100 })
198
+
199
+ // После изменения max, значение должно быть ограничено до 100
200
+ // Нужно обновить modelValue чтобы симулировать поведение родительского компонента
201
+ const maxChangeEvents = wrapper.emitted('update:modelValue') as any[][]
202
+ const newValue = maxChangeEvents[maxChangeEvents.length - 1][0]
203
+ await wrapper.setProps({ modelValue: newValue })
204
+
205
+ await slider.trigger('keydown.left', {
210
206
  shiftKey: true,
211
207
  })
212
- expect(input).toHaveBeenCalledWith(74)
208
+ const events10 = wrapper.emitted('update:modelValue') as any[][]
209
+ expect(events10[events10.length - 1]).toEqual([94])
213
210
 
214
- slider.trigger('keydown.right', {
211
+ await slider.trigger('keydown.right', {
215
212
  ctrlKey: true,
216
213
  })
217
- expect(input).toHaveBeenCalledWith(78)
218
- expect(input).toHaveBeenCalledTimes(12)
214
+ const events11 = wrapper.emitted('update:modelValue') as any[][]
215
+ expect(events11[events11.length - 1]).toEqual([98])
219
216
 
220
- wrapper.setProps({ disabled: true })
217
+ await wrapper.setProps({ disabled: true })
218
+ const eventsBeforeDisabled = wrapper.emitted('update:modelValue')?.length || 0
219
+ await slider.trigger('keydown.left')
220
+ // Количество событий не должно измениться
221
+ expect(wrapper.emitted('update:modelValue')?.length).toBe(eventsBeforeDisabled)
221
222
 
222
- slider.trigger('keydown.left')
223
-
224
- expect(input).toHaveBeenCalledTimes(12)
223
+ await wrapper.setProps({ disabled: false })
225
224
 
226
- wrapper.setProps({ disabled: false })
225
+ // Устанавливаем RTL режим
226
+ await wrapper.setProps({})
227
227
  wrapper.vm.$vuetify.rtl = true
228
228
 
229
- slider.trigger('keydown.right', {
229
+ await slider.trigger('keydown.right', {
230
230
  shiftKey: true,
231
231
  })
232
- expect(input).toHaveBeenCalledWith(72)
233
- wrapper.vm.$vuetify.rtl = undefined
232
+ const events12 = wrapper.emitted('update:modelValue') as any[][]
233
+ expect(events12[events12.length - 1]).toEqual([92])
234
234
  })
235
235
 
236
236
  it('should add for to label', () => {
237
237
  const wrapper = mountFunction({
238
- attachToDocument: true,
239
- attrs: { id: 'foo' },
240
- propsData: {
238
+ props: {
241
239
  label: 'bar',
242
240
  },
241
+ attrs: { id: 'foo' },
243
242
  })
244
243
 
245
244
  const label = wrapper.find('.v-label')
246
-
247
245
  expect(label.element.getAttribute('for')).toBe('foo')
248
246
 
249
247
  const wrapper2 = mountFunction({
250
- attachToDocument: true,
251
- propsData: {
248
+ props: {
252
249
  label: 'bar',
253
250
  },
254
251
  })
255
252
 
256
253
  const label2 = wrapper2.find('.v-label')
257
-
258
- expect(label2.element.getAttribute('for')).toBe(`input-${(wrapper2.vm as any)._uid}`)
254
+ expect(label2.element.getAttribute('for')).toBe(`input-${(wrapper2.vm as any).$.uid}`)
259
255
  })
260
256
 
261
257
  it('should deactivate', async () => {
262
- const wrapper = mountFunction({
263
- attachToDocument: true,
264
- })
265
-
258
+ const wrapper = mountFunction()
266
259
  const container = wrapper.find('.v-slider__thumb-container')
267
260
 
268
261
  expect(wrapper.vm.isActive).toBe(false)
269
-
270
- container.trigger('mousedown')
271
-
262
+ await container.trigger('mousedown')
272
263
  expect(wrapper.vm.isActive).toBe(true)
273
264
  })
274
265
 
275
266
  it('should react to touch', async () => {
276
- const wrapper = mountFunction({
277
- attachToDocument: true,
278
- })
279
-
267
+ const wrapper = mountFunction()
280
268
  const container = wrapper.find('.v-slider__thumb-container')
281
269
 
282
270
  expect(wrapper.vm.thumbPressed).toBe(false)
283
271
  expect(wrapper.vm.isActive).toBe(false)
284
272
 
285
- container.trigger('mousedown')
286
-
287
- await wrapper.vm.$nextTick()
288
-
273
+ await container.trigger('mousedown')
289
274
  expect(wrapper.vm.thumbPressed).toBe(true)
290
275
  expect(wrapper.vm.isActive).toBe(true)
291
276
 
292
- el.dispatchEvent(new Event('mouseup'))
293
-
277
+ wrapper.vm.app.dispatchEvent(new Event('mouseup'))
278
+ await wrapper.vm.$nextTick()
294
279
  expect(wrapper.vm.thumbPressed).toBe(false)
295
280
  expect(wrapper.vm.isActive).toBe(false)
296
281
 
297
- container.trigger('touchstart', {
282
+ await container.trigger('touchstart', {
298
283
  touches: [{}],
299
284
  })
300
-
301
- await wrapper.vm.$nextTick()
302
-
303
285
  expect(wrapper.vm.thumbPressed).toBe(true)
304
286
  expect(wrapper.vm.isActive).toBe(true)
305
287
 
306
- el.dispatchEvent(new Event('touchend'))
307
-
288
+ wrapper.vm.app.dispatchEvent(new Event('touchend'))
289
+ await wrapper.vm.$nextTick()
308
290
  expect(wrapper.vm.thumbPressed).toBe(false)
309
291
  expect(wrapper.vm.isActive).toBe(false)
310
292
  })
311
293
 
312
- it('should return a rounded value', () => {
294
+ it('should return a rounded value', async () => {
313
295
  const wrapper = mountFunction({
314
- propsData: { step: 0 },
296
+ props: { step: 0 },
315
297
  })
316
298
 
317
299
  expect(wrapper.vm.roundValue(1.234)).toBe(1.234)
318
300
 
319
- wrapper.setProps({ step: 1 })
320
-
301
+ await wrapper.setProps({ step: 1 })
321
302
  expect(wrapper.vm.roundValue(1.234)).toBe(1)
322
303
 
323
- wrapper.setProps({ step: 4 })
324
-
304
+ await wrapper.setProps({ step: 4 })
325
305
  expect(wrapper.vm.roundValue(5.667)).toBe(4)
326
-
327
306
  expect(wrapper.vm.roundValue(7.667)).toBe(8)
328
307
 
329
- wrapper.setProps({ step: 2.5 })
330
-
308
+ await wrapper.setProps({ step: 2.5 })
331
309
  expect(wrapper.vm.roundValue(5.667)).toBe(5)
332
310
  })
333
311
 
334
312
  it('should return a rounded value with offset', async () => {
335
313
  const wrapper = mountFunction({
336
- propsData: { step: 0 },
314
+ props: { step: 0 },
337
315
  })
338
316
 
339
317
  expect(wrapper.vm.roundValue(1.234)).toBe(1.234)
340
318
 
341
- wrapper.setProps({ step: 1 })
342
- await wrapper.vm.$nextTick()
343
-
319
+ await wrapper.setProps({ step: 1 })
344
320
  expect(wrapper.vm.roundValue(1.234)).toBe(1)
345
321
 
346
- wrapper.setProps({ step: 4, min: 2 })
347
- await wrapper.vm.$nextTick()
348
-
322
+ await wrapper.setProps({ step: 4, min: 2 })
349
323
  expect(wrapper.vm.roundValue(5.667)).toBe(6)
350
324
  expect(wrapper.vm.roundValue(7.667)).toBe(6)
351
325
 
352
- wrapper.setProps({ step: 2.5, min: 5 })
353
- await wrapper.vm.$nextTick()
354
-
326
+ await wrapper.setProps({ step: 2.5, min: 5 })
355
327
  expect(wrapper.vm.roundValue(5.667)).toBe(5)
356
328
  })
357
329
 
358
330
  it('should return a rounded value bounded by min and max', async () => {
359
331
  const wrapper = mountFunction({
360
- propsData: {
332
+ props: {
361
333
  min: 5,
362
334
  max: 10,
363
335
  },
364
336
  })
365
337
 
366
- wrapper.setProps({ value: 1 })
367
- await wrapper.vm.$nextTick()
338
+ await wrapper.setProps({ modelValue: 1 })
368
339
  expect(wrapper.vm.internalValue).toBe(5)
369
340
 
370
- wrapper.setProps({ value: 15 })
371
- await wrapper.vm.$nextTick()
341
+ await wrapper.setProps({ modelValue: 15 })
372
342
  expect(wrapper.vm.internalValue).toBe(10)
373
343
  })
374
344
 
375
345
  it('should not update if value matches lazy value', async () => {
376
346
  const wrapper = mountFunction({
377
- propsData: {
378
- value: 10,
347
+ props: {
348
+ modelValue: 10,
379
349
  },
380
350
  })
381
351
 
382
- const input = jest.fn()
383
- wrapper.vm.$on('input', input)
384
- await wrapper.vm.$nextTick()
385
-
386
352
  expect(wrapper.vm.lazyValue).toBe(10)
387
353
 
388
354
  wrapper.vm.internalValue = 15
389
-
390
- expect(input).toHaveBeenCalledTimes(1)
355
+ expect(wrapper.emitted('update:modelValue')?.length).toBe(1)
391
356
  expect(wrapper.vm.lazyValue).toBe(15)
392
357
 
393
358
  wrapper.vm.internalValue = 15
394
-
395
- expect(input).toHaveBeenCalledTimes(1)
359
+ expect(wrapper.emitted('update:modelValue')?.length).toBe(1)
396
360
  })
397
361
 
398
362
  it('should react to input events', async () => {
@@ -408,33 +372,26 @@ describe('VSlider.ts', () => {
408
372
  expect(wrapper.vm.isActive).toBe(false)
409
373
  expect(wrapper.vm.isFocused).toBe(false)
410
374
 
411
- input.trigger('focus')
412
-
375
+ await input.trigger('focus')
413
376
  expect(wrapper.vm.isFocused).toBe(true)
414
- expect(focus).toHaveBeenCalledTimes(1)
415
-
416
- input.trigger('blur')
377
+ expect(wrapper.emitted('focus')?.length).toBe(1)
417
378
 
379
+ await input.trigger('blur')
418
380
  expect(wrapper.vm.isFocused).toBe(false)
419
- expect(blur).toHaveBeenCalledTimes(1)
381
+ expect(wrapper.emitted('blur')?.length).toBe(1)
420
382
  })
421
383
 
422
384
  it('should call mousemove and emit change', () => {
423
385
  const wrapper = mountFunction()
424
-
425
- const change = jest.fn()
426
- wrapper.vm.$on('change', change)
427
386
  const input = wrapper.find('.v-slider')
428
387
 
429
388
  input.trigger('click')
430
-
431
- expect(change).toHaveBeenCalledTimes(1)
389
+ expect(wrapper.emitted('change')?.length).toBe(1)
432
390
  })
433
391
 
434
392
  it('should keep thumb-label when focused and clicked', async () => {
435
- const onBlur = jest.fn()
436
393
  const wrapper = mountFunction({
437
- propsData: {
394
+ props: {
438
395
  thumbLabel: true,
439
396
  },
440
397
  })
@@ -442,15 +399,15 @@ describe('VSlider.ts', () => {
442
399
  const input = wrapper.find('.v-slider__thumb-container')
443
400
  const thumb = wrapper.find('.v-slider__thumb-container')
444
401
 
445
- input.trigger('focus')
402
+ await input.trigger('focus')
446
403
 
447
404
  expect(wrapper.vm.showThumbLabel).toBe(true)
448
405
  expect(wrapper.vm.isActive).toBe(false)
449
406
  expect(wrapper.vm.isFocused).toBe(true)
450
407
 
451
408
  // Clicking thumb label triggers blur
452
- thumb.trigger('mousedown')
453
- input.trigger('blur')
409
+ await thumb.trigger('mousedown')
410
+ await input.trigger('blur')
454
411
 
455
412
  expect(wrapper.vm.isActive).toBe(true)
456
413
  expect(wrapper.vm.isFocused).toBe(false)
@@ -458,14 +415,12 @@ describe('VSlider.ts', () => {
458
415
 
459
416
  it('should reverse label location when inverse', async () => {
460
417
  const wrapper = mountFunction({
461
- propsData: { label: 'foo' },
418
+ props: { label: 'foo' },
462
419
  })
463
420
 
464
421
  expect(wrapper.html()).toMatchSnapshot()
465
422
 
466
- wrapper.setProps({ inverseLabel: true })
467
- await wrapper.vm.$nextTick()
468
-
423
+ await wrapper.setProps({ inverseLabel: true })
469
424
  expect(wrapper.html()).toMatchSnapshot()
470
425
  })
471
426
 
@@ -474,36 +429,26 @@ describe('VSlider.ts', () => {
474
429
 
475
430
  expect(wrapper.html()).toMatchSnapshot()
476
431
 
477
- wrapper.setProps({ value: 50 })
478
- await wrapper.vm.$nextTick()
479
-
432
+ await wrapper.setProps({ modelValue: 50 })
480
433
  expect(wrapper.html()).toMatchSnapshot()
481
434
 
482
- wrapper.setProps({ disabled: true })
483
- await wrapper.vm.$nextTick()
484
-
435
+ await wrapper.setProps({ disabled: true })
485
436
  expect(wrapper.html()).toMatchSnapshot()
486
437
 
487
438
  wrapper.vm.$vuetify.rtl = true
488
- wrapper.setProps({ value: 0, disabled: false })
489
- await wrapper.vm.$nextTick()
490
-
439
+ await wrapper.setProps({ modelValue: 0, disabled: false })
491
440
  expect(wrapper.html()).toMatchSnapshot()
492
441
 
493
- wrapper.setProps({ value: 50 })
494
- await wrapper.vm.$nextTick()
495
-
442
+ await wrapper.setProps({ modelValue: 50 })
496
443
  expect(wrapper.html()).toMatchSnapshot()
497
444
 
498
- wrapper.setProps({ disabled: true })
499
- await wrapper.vm.$nextTick()
500
-
445
+ await wrapper.setProps({ disabled: true })
501
446
  expect(wrapper.html()).toMatchSnapshot()
502
447
  })
503
448
 
504
449
  it('should display label and have different aria-label', () => {
505
450
  const wrapper = mountFunction({
506
- propsData: { label: 'foo' },
451
+ props: { label: 'foo' },
507
452
  attrs: { 'aria-label': 'bar' },
508
453
  })
509
454
 
@@ -512,7 +457,7 @@ describe('VSlider.ts', () => {
512
457
 
513
458
  it('should display tick labels', () => {
514
459
  const wrapper = mountFunction({
515
- propsData: {
460
+ props: {
516
461
  max: 1,
517
462
  tickLabels: ['foo', 'bar'],
518
463
  },
@@ -521,131 +466,88 @@ describe('VSlider.ts', () => {
521
466
  const ticks = wrapper.findAll('.v-slider__tick')
522
467
 
523
468
  expect(ticks).toHaveLength(2)
524
- expect((ticks.at(0).element.firstChild as HTMLElement).innerHTML).toBe('foo')
525
- expect((ticks.at(1).element.firstChild as HTMLElement).innerHTML).toBe('bar')
469
+ expect((ticks[0].element.firstChild as HTMLElement).innerHTML).toBe('foo')
470
+ expect((ticks[1].element.firstChild as HTMLElement).innerHTML).toBe('bar')
526
471
  })
527
472
 
528
- it('should not react to keydown if disabled', () => {
529
- const parseKeyDown = jest.fn()
473
+ it('should not react to keydown if disabled', async () => {
530
474
  const wrapper = mountFunction({
531
- propsData: { disabled: true },
532
- methods: { parseKeyDown },
475
+ props: { disabled: true, modelValue: 50 },
533
476
  })
534
477
 
535
478
  const input = wrapper.find('.v-slider__thumb-container')
536
479
 
537
- input.trigger('keydown.right')
480
+ // Тестируем disabled состояние
481
+ await input.trigger('keydown.right')
482
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
538
483
 
539
- expect(parseKeyDown).not.toHaveBeenCalled()
540
-
541
- wrapper.setProps({
484
+ // Тестируем readonly состояние
485
+ await wrapper.setProps({
542
486
  disabled: false,
543
487
  readonly: true,
544
488
  })
489
+ await input.trigger('keydown.right')
490
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
545
491
 
546
- input.trigger('keydown.right')
547
-
548
- expect(parseKeyDown).not.toHaveBeenCalled()
549
-
550
- wrapper.setProps({
492
+ // Тестируем нормальное состояние
493
+ await wrapper.setProps({
551
494
  disabled: false,
552
495
  readonly: false,
553
496
  })
554
-
555
- input.trigger('keydown.right')
556
-
557
- expect(parseKeyDown).toHaveBeenCalled()
497
+ const eventsBefore = wrapper.emitted('update:modelValue')?.length || 0
498
+ await input.trigger('keydown.right')
499
+ const eventsAfter = wrapper.emitted('update:modelValue')?.length || 0
500
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy()
501
+ expect(eventsAfter).toBeGreaterThan(eventsBefore)
558
502
  })
559
503
 
560
504
  it('should set value to min value if given a NaN value', () => {
561
- const input = jest.fn()
562
- mountFunction({
563
- propsData: {
564
- min: -20,
565
- max: 20,
566
- value: NaN,
567
- },
568
- listeners: {
569
- input,
570
- },
571
- })
572
-
573
- expect(input).toHaveBeenCalledTimes(1)
574
- expect(input).toHaveBeenCalledWith(-20)
575
- })
576
-
577
- it('should correctly handle initial value of zero (#7320)', () => {
578
- const input = jest.fn()
579
505
  const wrapper = mountFunction({
580
- propsData: {
506
+ props: {
581
507
  min: -20,
582
508
  max: 20,
583
- value: 0,
584
- },
585
- listeners: {
586
- input,
509
+ modelValue: NaN,
587
510
  },
588
511
  })
589
512
 
590
- expect(input).not.toHaveBeenCalledWith(-20)
591
- expect(wrapper.html()).toMatchSnapshot()
513
+ expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([-20])
592
514
  })
593
515
 
594
- // TODO: this fails without sync, nextTick doesn't help
595
- // https://github.com/vuejs/vue-test-utils/issues/1130
596
- it.skip('should correctly handle setting value to zero (#7320)', async () => {
597
- const input = jest.fn()
516
+ it('should correctly handle initial value of zero (#7320)', () => {
598
517
  const wrapper = mountFunction({
599
- propsData: {
518
+ props: {
600
519
  min: -20,
601
520
  max: 20,
602
- value: 10,
603
- },
604
- listeners: {
605
- input,
521
+ modelValue: 0,
606
522
  },
607
523
  })
608
524
 
609
- wrapper.setProps({
610
- value: 0,
611
- })
612
- await wrapper.vm.$nextTick()
613
-
614
- expect(input).not.toHaveBeenCalledWith(-20)
525
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
615
526
  expect(wrapper.html()).toMatchSnapshot()
616
527
  })
617
528
 
618
- // https://github.com/vuetifyjs/vuetify/issues/10018
619
529
  it('should not fire event if value is provided and valid', async () => {
620
- const input = jest.fn()
621
- mountFunction({
622
- propsData: { value: 10, min: -20 },
623
- listeners: { input },
530
+ const wrapper = mountFunction({
531
+ props: { modelValue: 10, min: -20 },
624
532
  })
625
533
 
626
- expect(input).not.toHaveBeenCalled()
534
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
627
535
 
628
536
  // Should set to min value if invalid
629
- mountFunction({
630
- propsData: { value: NaN, min: -20 },
631
- listeners: { input },
537
+ const wrapper2 = mountFunction({
538
+ props: { modelValue: NaN, min: -20 },
632
539
  })
633
540
 
634
- expect(input).toHaveBeenCalledWith(-20)
541
+ expect(wrapper2.emitted('update:modelValue')?.[0]).toEqual([-20])
635
542
  })
636
543
 
637
- // https://github.com/vuetifyjs/vuetify/issues/11569
638
544
  it('should not fire change event onKeyDown if value is invalid', () => {
639
- const change = jest.fn()
640
545
  const wrapper = mountFunction({
641
- propsData: { min: 1 },
642
- listeners: { change },
546
+ props: { min: 1 },
643
547
  })
644
548
 
645
549
  const slider = wrapper.find('.v-slider__thumb-container')
646
-
647
550
  slider.trigger('keydown.left')
648
-
649
- expect(change).not.toHaveBeenCalled()
551
+ expect(wrapper.emitted('change')).toBeFalsy()
650
552
  })
651
553
  })