@dimailn/vuetify 2.7.2-alpha21 → 2.7.2-alpha22

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 (67) hide show
  1. package/dist/vuetify.js +89 -40
  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/VOverlay/VOverlay.js +2 -3
  6. package/es5/components/VOverlay/VOverlay.js.map +1 -1
  7. package/es5/components/VProgressCircular/VProgressCircular.js +5 -3
  8. package/es5/components/VProgressCircular/VProgressCircular.js.map +1 -1
  9. package/es5/components/VProgressLinear/VProgressLinear.js +41 -19
  10. package/es5/components/VProgressLinear/VProgressLinear.js.map +1 -1
  11. package/es5/components/VTabs/VTabsBar.js.map +1 -1
  12. package/es5/components/VVirtualScroll/VVirtualScroll.js +15 -16
  13. package/es5/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
  14. package/es5/components/VWindow/VWindow.js +13 -5
  15. package/es5/components/VWindow/VWindow.js.map +1 -1
  16. package/es5/components/VWindow/VWindowItem.js +9 -5
  17. package/es5/components/VWindow/VWindowItem.js.map +1 -1
  18. package/es5/framework.js +1 -1
  19. package/es5/mixins/overlayable/index.js.map +1 -1
  20. package/lib/components/VOverlay/VOverlay.js +1 -2
  21. package/lib/components/VOverlay/VOverlay.js.map +1 -1
  22. package/lib/components/VProgressCircular/VProgressCircular.js +5 -3
  23. package/lib/components/VProgressCircular/VProgressCircular.js.map +1 -1
  24. package/lib/components/VProgressLinear/VProgressLinear.js +35 -17
  25. package/lib/components/VProgressLinear/VProgressLinear.js.map +1 -1
  26. package/lib/components/VTabs/VTabsBar.js.map +1 -1
  27. package/lib/components/VVirtualScroll/VVirtualScroll.js +8 -11
  28. package/lib/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
  29. package/lib/components/VWindow/VWindow.js +7 -3
  30. package/lib/components/VWindow/VWindow.js.map +1 -1
  31. package/lib/components/VWindow/VWindowItem.js +3 -1
  32. package/lib/components/VWindow/VWindowItem.js.map +1 -1
  33. package/lib/framework.js +1 -1
  34. package/lib/mixins/overlayable/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/VAvatar/__tests__/VAvatar.spec.ts +72 -10
  37. package/src/components/VOverlay/VOverlay.ts +1 -1
  38. package/src/components/VOverlay/__tests__/VOverlay.spec.ts +6 -6
  39. package/src/components/VProgressCircular/VProgressCircular.ts +6 -5
  40. package/src/components/VProgressCircular/__tests__/VProgressCircular.spec.ts +28 -21
  41. package/src/components/VProgressCircular/__tests__/__snapshots__/VProgressCircular.spec.ts.snap +62 -62
  42. package/src/components/VProgressLinear/VProgressLinear.ts +42 -22
  43. package/src/components/VProgressLinear/__tests__/VProgressLinear.spec.ts +378 -71
  44. package/src/components/VProgressLinear/__tests__/__snapshots__/VProgressLinear.spec.ts.snap +53 -79
  45. package/src/components/VSheet/__tests__/VSheet.spec.ts +5 -5
  46. package/src/components/VTabs/VTabsBar.ts +7 -5
  47. package/src/components/VVirtualScroll/VVirtualScroll.ts +14 -13
  48. package/src/components/VVirtualScroll/__tests__/VVirtualScroll.spec.ts +26 -19
  49. package/src/components/VWindow/VWindow.ts +9 -5
  50. package/src/components/VWindow/VWindowItem.ts +3 -1
  51. package/src/components/VWindow/__tests__/VWindow.spec.ts +226 -185
  52. package/src/components/VWindow/__tests__/VWindowItem.spec.ts +162 -132
  53. package/src/mixins/applicationable/__tests__/applicationable.spec.ts +31 -27
  54. package/src/mixins/colorable/__tests__/colorable.spec.ts +9 -6
  55. package/src/mixins/elevatable/__tests__/elevatable.spec.ts +14 -13
  56. package/src/mixins/intersectable/__tests__/intersectable.spec.ts +35 -29
  57. package/src/mixins/menuable/__tests__/menuable.spec.ts +76 -33
  58. package/src/mixins/mobile/__tests__/mobile.spec.ts +9 -6
  59. package/src/mixins/overlayable/__tests__/overlayable.spec.ts +32 -24
  60. package/src/mixins/overlayable/index.ts +1 -1
  61. package/src/mixins/proxyable/__tests__/proxyable.spec.ts +18 -17
  62. package/src/mixins/registrable/__tests__/registrable.spec.ts +31 -0
  63. package/src/mixins/rippleable/__tests__/rippleable.spec.ts +10 -9
  64. package/src/mixins/roundable/__tests__/roundable.spec.ts +7 -5
  65. package/src/mixins/routable/__tests__/routable.spec.ts +60 -52
  66. package/src/mixins/scrollable/__tests__/scrollable.spec.ts +56 -27
  67. package/src/mixins/selectable/__tests__/selectable.spec.ts +22 -9
@@ -4,13 +4,16 @@ import VProgressLinear from '../VProgressLinear'
4
4
  // Utilities
5
5
  import {
6
6
  mount,
7
- Wrapper,
7
+ VueWrapper,
8
+ enableAutoUnmount,
8
9
  } from '@vue/test-utils'
9
- import { compileToFunctions } from 'vue-template-compiler'
10
+ import { h } from 'vue'
10
11
 
11
12
  describe('VProgressLinear.ts', () => {
12
13
  type Instance = InstanceType<typeof VProgressLinear>
13
- let mountFunction: (options?: object) => Wrapper<Instance>
14
+ let mountFunction: (options?: object) => VueWrapper<Instance>
15
+
16
+ enableAutoUnmount(afterEach)
14
17
 
15
18
  beforeEach(() => {
16
19
  mountFunction = (options = {}) => {
@@ -18,9 +21,11 @@ describe('VProgressLinear.ts', () => {
18
21
  data: () => ({
19
22
  isVisible: false,
20
23
  }),
21
- mocks: {
22
- $vuetify: {
23
- rtl: false,
24
+ global: {
25
+ mocks: {
26
+ $vuetify: {
27
+ rtl: false,
28
+ },
24
29
  },
25
30
  },
26
31
  ...options,
@@ -28,41 +33,41 @@ describe('VProgressLinear.ts', () => {
28
33
  }
29
34
  })
30
35
 
31
- it('should render component and match snapshot', () => {
36
+ it('should render component and match snapshot', async () => {
32
37
  const wrapper = mountFunction({
33
- propsData: {
38
+ props: {
34
39
  value: 33,
35
40
  },
36
41
  })
37
42
 
38
43
  expect(wrapper.html()).toMatchSnapshot()
39
44
 
40
- wrapper.setProps({ value: -1, bufferValue: -1 })
45
+ await wrapper.setProps({ value: -1, bufferValue: -1 })
41
46
  const htmlMinus1 = wrapper.html()
42
47
 
43
- wrapper.setProps({ value: 0, bufferValue: 0 })
48
+ await wrapper.setProps({ value: 0, bufferValue: 0 })
44
49
  const html0 = wrapper.html()
45
50
 
46
- wrapper.setProps({ value: 100, bufferValue: 100 })
51
+ await wrapper.setProps({ value: 100, bufferValue: 100 })
47
52
  const html100 = wrapper.html()
48
53
 
49
- wrapper.setProps({ value: 101, bufferValue: 101 })
54
+ await wrapper.setProps({ value: 101, bufferValue: 101 })
50
55
  const html101 = wrapper.html()
51
56
 
52
57
  expect(htmlMinus1).toBe(html0)
53
58
  expect(html100).toBe(html101)
54
59
  expect(html0).not.toBe(html100)
55
60
 
56
- wrapper.setProps({ value: '-1', bufferValue: '-1' })
61
+ await wrapper.setProps({ value: '-1', bufferValue: '-1' })
57
62
  const htmlMinus1String = wrapper.html()
58
63
 
59
- wrapper.setProps({ value: '0', bufferValue: '0' })
64
+ await wrapper.setProps({ value: '0', bufferValue: '0' })
60
65
  const html0String = wrapper.html()
61
66
 
62
- wrapper.setProps({ value: '100', bufferValue: '100' })
67
+ await wrapper.setProps({ value: '100', bufferValue: '100' })
63
68
  const html100String = wrapper.html()
64
69
 
65
- wrapper.setProps({ value: '101', bufferValue: '101' })
70
+ await wrapper.setProps({ value: '101', bufferValue: '101' })
66
71
  const html101String = wrapper.html()
67
72
 
68
73
  expect(htmlMinus1String).toBe(html0String)
@@ -72,7 +77,7 @@ describe('VProgressLinear.ts', () => {
72
77
 
73
78
  it('should render inactive component and match snapshot', () => {
74
79
  const wrapper = mountFunction({
75
- propsData: {
80
+ props: {
76
81
  value: 33,
77
82
  active: false,
78
83
  },
@@ -83,12 +88,14 @@ describe('VProgressLinear.ts', () => {
83
88
 
84
89
  it('should render component in RTL mode', () => {
85
90
  const wrapper = mountFunction({
86
- propsData: {
91
+ props: {
87
92
  value: 33,
88
93
  },
89
- mocks: {
90
- $vuetify: {
91
- rtl: true,
94
+ global: {
95
+ mocks: {
96
+ $vuetify: {
97
+ rtl: true,
98
+ },
92
99
  },
93
100
  },
94
101
  })
@@ -98,7 +105,7 @@ describe('VProgressLinear.ts', () => {
98
105
 
99
106
  it('should render reversed component', () => {
100
107
  const wrapper = mountFunction({
101
- propsData: {
108
+ props: {
102
109
  reverse: true,
103
110
  value: 33,
104
111
  },
@@ -109,12 +116,14 @@ describe('VProgressLinear.ts', () => {
109
116
 
110
117
  it('should render reverse component in RTL mode', () => {
111
118
  const wrapper = mountFunction({
112
- propsData: {
119
+ props: {
113
120
  reverse: true,
114
121
  value: 33,
115
122
  },
116
- mocks: {
117
- $vuetify: { rtl: true },
123
+ global: {
124
+ mocks: {
125
+ $vuetify: { rtl: true },
126
+ },
118
127
  },
119
128
  })
120
129
 
@@ -123,9 +132,9 @@ describe('VProgressLinear.ts', () => {
123
132
 
124
133
  it('should render component with color and match snapshot', () => {
125
134
  const wrapper = mountFunction({
126
- propsData: {
135
+ props: {
127
136
  value: 33,
128
- color: 'orange',
137
+ color: 'red',
129
138
  },
130
139
  })
131
140
 
@@ -134,9 +143,9 @@ describe('VProgressLinear.ts', () => {
134
143
 
135
144
  it('should render component with css color and match snapshot', () => {
136
145
  const wrapper = mountFunction({
137
- propsData: {
146
+ props: {
138
147
  value: 33,
139
- color: '#336699',
148
+ color: '#FF0000',
140
149
  },
141
150
  })
142
151
 
@@ -145,9 +154,9 @@ describe('VProgressLinear.ts', () => {
145
154
 
146
155
  it('should render component with color and background opacity and match snapshot', () => {
147
156
  const wrapper = mountFunction({
148
- propsData: {
157
+ props: {
149
158
  value: 33,
150
- color: 'orange',
159
+ color: 'red',
151
160
  backgroundOpacity: 0.5,
152
161
  },
153
162
  })
@@ -157,9 +166,9 @@ describe('VProgressLinear.ts', () => {
157
166
 
158
167
  it('should render component with color and background color and match snapshot', () => {
159
168
  const wrapper = mountFunction({
160
- propsData: {
169
+ props: {
161
170
  value: 33,
162
- color: 'orange',
171
+ color: 'red',
163
172
  backgroundColor: 'blue',
164
173
  },
165
174
  })
@@ -169,9 +178,9 @@ describe('VProgressLinear.ts', () => {
169
178
 
170
179
  it('should render component with color and background color and opacity and match snapshot', () => {
171
180
  const wrapper = mountFunction({
172
- propsData: {
181
+ props: {
173
182
  value: 33,
174
- color: 'orange',
183
+ color: 'red',
175
184
  backgroundColor: 'blue',
176
185
  backgroundOpacity: 0.5,
177
186
  },
@@ -182,7 +191,7 @@ describe('VProgressLinear.ts', () => {
182
191
 
183
192
  it('should render indeterminate progress and match snapshot', () => {
184
193
  const wrapper = mountFunction({
185
- propsData: {
194
+ props: {
186
195
  indeterminate: true,
187
196
  },
188
197
  })
@@ -192,7 +201,7 @@ describe('VProgressLinear.ts', () => {
192
201
 
193
202
  it('should render indeterminate progress with query prop and match snapshot', () => {
194
203
  const wrapper = mountFunction({
195
- propsData: {
204
+ props: {
196
205
  indeterminate: true,
197
206
  query: true,
198
207
  },
@@ -201,26 +210,20 @@ describe('VProgressLinear.ts', () => {
201
210
  expect(wrapper.html()).toMatchSnapshot()
202
211
  })
203
212
 
204
- it('should render component with buffer value and match snapshot', async () => {
213
+ it('should render component with buffer value and match snapshot', () => {
205
214
  const wrapper = mountFunction({
206
- propsData: {
215
+ props: {
207
216
  value: 33,
208
217
  bufferValue: 80,
209
218
  },
210
219
  })
211
220
 
212
221
  expect(wrapper.html()).toMatchSnapshot()
213
-
214
- wrapper.setProps({
215
- bufferValue: 0,
216
- })
217
- await wrapper.vm.$nextTick()
218
- expect(wrapper.html()).toMatchSnapshot()
219
222
  })
220
223
 
221
224
  it('should render component with buffer value and value > buffer value and match snapshot', () => {
222
225
  const wrapper = mountFunction({
223
- propsData: {
226
+ props: {
224
227
  value: 90,
225
228
  bufferValue: 80,
226
229
  },
@@ -231,58 +234,362 @@ describe('VProgressLinear.ts', () => {
231
234
 
232
235
  it('should render default slot content', () => {
233
236
  const wrapper = mountFunction({
234
- propsData: {
235
- value: 90,
236
- bufferValue: 80,
237
+ slots: {
238
+ default: ({ value }) => h('div', { class: 'slot-content' }, `Progress: ${value}%`)
239
+ }
240
+ })
241
+
242
+ expect(wrapper.find('.slot-content').exists()).toBe(true)
243
+ expect(wrapper.find('.slot-content').text()).toBe('Progress: 0%')
244
+ })
245
+
246
+ it('should render slot content with custom value', () => {
247
+ const wrapper = mountFunction({
248
+ props: {
249
+ value: 75,
237
250
  },
238
251
  slots: {
239
- default: [compileToFunctions('<div class="foobar">content</div>')],
252
+ default: ({ value }) => h('div', { class: 'slot-content' }, `Custom: ${value}%`)
253
+ }
254
+ })
255
+
256
+ expect(wrapper.find('.slot-content').exists()).toBe(true)
257
+ expect(wrapper.find('.slot-content').text()).toBe('Custom: 75%')
258
+ })
259
+
260
+ it('should respond to click events', async () => {
261
+ const wrapper = mountFunction({
262
+ props: {
263
+ value: 33,
240
264
  },
265
+ attrs: {
266
+ 'onUpdate:modelValue': () => {},
267
+ onChange: () => {},
268
+ },
269
+ attachTo: document.body, // Важно для корректной работы событий
241
270
  })
242
271
 
243
- expect(wrapper.html()).toMatchSnapshot()
244
- expect(wrapper.findAll('.foobar')).toHaveLength(1)
272
+ // Находим элемент прогресс-бара
273
+ const progressBar = wrapper.find('.v-progress-linear')
274
+
275
+ // Мокаем getBoundingClientRect для элемента
276
+ const mockRect = {
277
+ width: 400,
278
+ height: 20,
279
+ top: 0,
280
+ left: 0,
281
+ right: 400,
282
+ bottom: 20,
283
+ }
284
+
285
+ // Мокаем offsetX для события клика
286
+ const originalOffsetX = Object.getOwnPropertyDescriptor(MouseEvent.prototype, 'offsetX')
287
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', {
288
+ get: () => 200, // 50% от ширины
289
+ configurable: true
290
+ })
291
+
292
+ // Мокаем getBoundingClientRect
293
+ const originalGetBoundingClientRect = progressBar.element.getBoundingClientRect
294
+ progressBar.element.getBoundingClientRect = jest.fn().mockReturnValue(mockRect)
295
+
296
+ try {
297
+ // Триггерим событие клика
298
+ await progressBar.trigger('click')
299
+
300
+ // Проверяем, что событие эмитится
301
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy()
302
+
303
+ // Проверяем, что последнее значение примерно 50%
304
+ const emittedValues = wrapper.emitted('update:modelValue')
305
+ if (emittedValues && emittedValues.length > 0) {
306
+ const lastValue = emittedValues[emittedValues.length - 1][0]
307
+ expect(lastValue).toBeCloseTo(50, 0) // Проверяем с точностью до целого
308
+ }
309
+ } finally {
310
+ // Восстанавливаем оригинальные методы
311
+ if (originalOffsetX) {
312
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', originalOffsetX)
313
+ }
314
+ progressBar.element.getBoundingClientRect = originalGetBoundingClientRect
315
+ }
316
+ })
317
+
318
+ it('should not respond to click events when not reactive', async () => {
319
+ const wrapper = mountFunction({
320
+ props: {
321
+ value: 33,
322
+ },
323
+ attachTo: document.body,
324
+ })
325
+
326
+ // Убираем все слушатели событий
327
+ const progressBar = wrapper.find('.v-progress-linear')
328
+
329
+ // Мокаем getBoundingClientRect
330
+ const mockRect = {
331
+ width: 400,
332
+ height: 20,
333
+ top: 0,
334
+ left: 0,
335
+ right: 400,
336
+ bottom: 20,
337
+ }
338
+
339
+ const originalGetBoundingClientRect = progressBar.element.getBoundingClientRect
340
+ progressBar.element.getBoundingClientRect = jest.fn().mockReturnValue(mockRect)
341
+
342
+ try {
343
+ // Триггерим событие клика
344
+ await progressBar.trigger('click')
345
+
346
+ // Проверяем, что событие не эмитится
347
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy()
348
+ } finally {
349
+ // Восстанавливаем оригинальный метод
350
+ progressBar.element.getBoundingClientRect = originalGetBoundingClientRect
351
+ }
245
352
  })
246
353
 
247
- it('should respond to click events', () => {
248
- const change = jest.fn()
354
+ it('should emit update:modelValue when clicked', async () => {
249
355
  const wrapper = mountFunction({
250
- attachToDocument: true,
251
- propsData: {
252
- value: 0,
356
+ props: {
357
+ modelValue: 0,
358
+ },
359
+ attrs: {
360
+ 'onUpdate:modelValue': () => {},
361
+ onChange: () => {},
253
362
  },
254
- listeners: { change },
363
+ attachTo: document.body,
364
+ })
365
+
366
+ const progressBar = wrapper.find('.v-progress-linear')
367
+
368
+ // Мокаем getBoundingClientRect
369
+ const mockRect = {
370
+ width: 400,
371
+ height: 20,
372
+ top: 0,
373
+ left: 0,
374
+ right: 400,
375
+ bottom: 20,
376
+ }
377
+
378
+ // Мокаем offsetX для 75% позиции
379
+ const originalOffsetX = Object.getOwnPropertyDescriptor(MouseEvent.prototype, 'offsetX')
380
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', {
381
+ get: () => 300, // 75% от ширины
382
+ configurable: true
255
383
  })
256
384
 
257
- const rect = wrapper.vm.$el.getBoundingClientRect()
385
+ const originalGetBoundingClientRect = progressBar.element.getBoundingClientRect
386
+ progressBar.element.getBoundingClientRect = jest.fn().mockReturnValue(mockRect)
387
+
388
+ try {
389
+ // Триггерим событие клика
390
+ await progressBar.trigger('click')
391
+
392
+ // Проверяем, что событие эмитится с правильным значением
393
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy()
394
+ const emittedValues = wrapper.emitted('update:modelValue')
395
+ if (emittedValues && emittedValues.length > 0) {
396
+ const lastValue = emittedValues[emittedValues.length - 1][0]
397
+ expect(lastValue).toBeCloseTo(75, 0)
398
+ }
399
+ } finally {
400
+ // Восстанавливаем оригинальные методы
401
+ if (originalOffsetX) {
402
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', originalOffsetX)
403
+ }
404
+ progressBar.element.getBoundingClientRect = originalGetBoundingClientRect
405
+ }
406
+ })
258
407
 
259
- wrapper.vm.$el.getBoundingClientRect = () => ({
260
- ...rect,
261
- width: 1000,
408
+ it('should handle edge cases in click events', async () => {
409
+ const wrapper = mountFunction({
410
+ props: {
411
+ modelValue: 0,
412
+ },
413
+ attrs: {
414
+ 'onUpdate:modelValue': () => {},
415
+ onChange: () => {},
416
+ },
417
+ attachTo: document.body,
262
418
  })
263
419
 
264
- expect(wrapper.vm.internalLazyValue).toBe(0)
420
+ const progressBar = wrapper.find('.v-progress-linear')
421
+
422
+ // Мокаем getBoundingClientRect
423
+ const mockRect = {
424
+ width: 400,
425
+ height: 20,
426
+ top: 0,
427
+ left: 0,
428
+ right: 400,
429
+ bottom: 20,
430
+ }
431
+
432
+ const originalGetBoundingClientRect = progressBar.element.getBoundingClientRect
433
+ progressBar.element.getBoundingClientRect = jest.fn().mockReturnValue(mockRect)
434
+
435
+ try {
436
+ // Клик по левому краю (0%)
437
+ const originalOffsetXLeft = Object.getOwnPropertyDescriptor(MouseEvent.prototype, 'offsetX')
438
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', {
439
+ get: () => 0,
440
+ configurable: true
441
+ })
442
+
443
+ await progressBar.trigger('click')
265
444
 
266
- wrapper.trigger('click', { offsetX: 200 })
445
+ // Проверяем, что значение 0%
446
+ const emittedValuesLeft = wrapper.emitted('update:modelValue')
447
+ if (emittedValuesLeft && emittedValuesLeft.length > 0) {
448
+ const lastValue = emittedValuesLeft[emittedValuesLeft.length - 1][0]
449
+ expect(lastValue).toBeCloseTo(0, 0)
450
+ }
267
451
 
268
- expect(wrapper.vm.internalLazyValue).toBe(20)
452
+ // Клик по правому краю (100%)
453
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', {
454
+ get: () => 400,
455
+ configurable: true
456
+ })
457
+
458
+ await progressBar.trigger('click')
459
+
460
+ // Проверяем, что значение 100%
461
+ const emittedValuesRight = wrapper.emitted('update:modelValue')
462
+ if (emittedValuesRight && emittedValuesRight.length > 0) {
463
+ const lastValue = emittedValuesRight[emittedValuesRight.length - 1][0]
464
+ expect(lastValue).toBeCloseTo(100, 0)
465
+ }
466
+
467
+ // Восстанавливаем оригинальное свойство
468
+ if (originalOffsetXLeft) {
469
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', originalOffsetXLeft)
470
+ }
471
+ } finally {
472
+ // Восстанавливаем оригинальный метод
473
+ progressBar.element.getBoundingClientRect = originalGetBoundingClientRect
474
+ }
269
475
  })
270
476
 
271
477
  it('should render a stream component', () => {
272
478
  const wrapper = mountFunction({
273
- propsData: {
479
+ props: {
480
+ value: 33,
274
481
  stream: true,
275
482
  },
276
483
  })
277
484
 
278
- expect(wrapper.find('.v-progress-linear__stream')).toBeTruthy()
485
+ expect(wrapper.html()).toMatchSnapshot()
279
486
  })
280
487
 
281
488
  it('should set isVisible with onObserve', () => {
282
- expect((new VProgressLinear()).isVisible).toEqual(true)
283
489
  const wrapper = mountFunction()
284
- expect(wrapper.vm.isVisible).toEqual(false)
285
- wrapper.vm.onObserve(null, null, true)
286
- expect(wrapper.vm.isVisible).toEqual(true)
490
+
491
+ const entries = [
492
+ {
493
+ isIntersecting: true,
494
+ },
495
+ ] as IntersectionObserverEntry[]
496
+
497
+ wrapper.vm.onObserve(entries, {} as IntersectionObserver, true)
498
+
499
+ expect(wrapper.vm.isVisible).toBe(true)
500
+ })
501
+
502
+ it('should work with v-model', async () => {
503
+ const wrapper = mountFunction({
504
+ props: {
505
+ modelValue: 25,
506
+ },
507
+ })
508
+
509
+ // Проверяем начальное значение
510
+ expect(wrapper.vm.internalLazyValue).toBe(25)
511
+ expect(wrapper.vm.normalizedValue).toBe(25)
512
+
513
+ // Изменяем значение через v-model
514
+ await wrapper.setProps({ modelValue: 75 })
515
+
516
+ // Проверяем, что значение обновилось
517
+ expect(wrapper.vm.internalLazyValue).toBe(75)
518
+ expect(wrapper.vm.normalizedValue).toBe(75)
519
+ })
520
+
521
+ it('should work with v-model and click events', async () => {
522
+ const wrapper = mountFunction({
523
+ props: {
524
+ modelValue: 0,
525
+ },
526
+ attrs: {
527
+ 'onUpdate:modelValue': () => {},
528
+ onChange: () => {},
529
+ },
530
+ attachTo: document.body,
531
+ })
532
+
533
+ const progressBar = wrapper.find('.v-progress-linear')
534
+
535
+ // Мокаем getBoundingClientRect
536
+ const mockRect = {
537
+ width: 400,
538
+ height: 20,
539
+ top: 0,
540
+ left: 0,
541
+ right: 400,
542
+ bottom: 20,
543
+ }
544
+
545
+ // Мокаем offsetX для 60% позиции
546
+ const originalOffsetX = Object.getOwnPropertyDescriptor(MouseEvent.prototype, 'offsetX')
547
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', {
548
+ get: () => 240, // 60% от ширины
549
+ configurable: true
550
+ })
551
+
552
+ const originalGetBoundingClientRect = progressBar.element.getBoundingClientRect
553
+ progressBar.element.getBoundingClientRect = jest.fn().mockReturnValue(mockRect)
554
+
555
+ try {
556
+ // Триггерим событие клика
557
+ await progressBar.trigger('click')
558
+
559
+ // Проверяем, что событие эмитится
560
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy()
561
+
562
+ // Проверяем, что значение примерно 60%
563
+ const emittedValues = wrapper.emitted('update:modelValue')
564
+ if (emittedValues && emittedValues.length > 0) {
565
+ const lastValue = emittedValues[emittedValues.length - 1][0]
566
+ expect(lastValue).toBeCloseTo(60, 0)
567
+ }
568
+ } finally {
569
+ // Восстанавливаем оригинальные методы
570
+ if (originalOffsetX) {
571
+ Object.defineProperty(MouseEvent.prototype, 'offsetX', originalOffsetX)
572
+ }
573
+ progressBar.element.getBoundingClientRect = originalGetBoundingClientRect
574
+ }
575
+ })
576
+
577
+ it('should maintain backward compatibility with value prop', async () => {
578
+ const wrapper = mountFunction({
579
+ props: {
580
+ value: 30,
581
+ },
582
+ })
583
+
584
+ // Проверяем, что работает старый prop value
585
+ expect(wrapper.vm.internalLazyValue).toBe(30)
586
+ expect(wrapper.vm.normalizedValue).toBe(30)
587
+
588
+ // Изменяем значение через value
589
+ await wrapper.setProps({ value: 80 })
590
+
591
+ // Проверяем, что значение обновилось
592
+ expect(wrapper.vm.internalLazyValue).toBe(80)
593
+ expect(wrapper.vm.normalizedValue).toBe(80)
287
594
  })
288
595
  })