@dimailn/vuetify 2.7.2-alpha23 → 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 (108) hide show
  1. package/dist/vuetify.js +280 -256
  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/VBadge/VBadge.js +17 -14
  6. package/es5/components/VBadge/VBadge.js.map +1 -1
  7. package/es5/components/VBtn/VBtn.js +16 -16
  8. package/es5/components/VBtn/VBtn.js.map +1 -1
  9. package/es5/components/VColorPicker/VColorPicker.js +18 -31
  10. package/es5/components/VColorPicker/VColorPicker.js.map +1 -1
  11. package/es5/components/VColorPicker/VColorPickerCanvas.js +45 -46
  12. package/es5/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  13. package/es5/components/VColorPicker/VColorPickerEdit.js +27 -26
  14. package/es5/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  15. package/es5/components/VColorPicker/VColorPickerPreview.js +41 -30
  16. package/es5/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  17. package/es5/components/VColorPicker/VColorPickerSwatches.js +13 -10
  18. package/es5/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  19. package/es5/components/VDataTable/VDataTable.js +7 -11
  20. package/es5/components/VDataTable/VDataTable.js.map +1 -1
  21. package/es5/components/VInput/VInput.js +24 -6
  22. package/es5/components/VInput/VInput.js.map +1 -1
  23. package/es5/components/VSelect/VSelectList.js +1 -1
  24. package/es5/components/VSelect/VSelectList.js.map +1 -1
  25. package/es5/components/VSlider/VSlider.js +23 -18
  26. package/es5/components/VSlider/VSlider.js.map +1 -1
  27. package/es5/components/VTooltip/VTooltip.js +3 -7
  28. package/es5/components/VTooltip/VTooltip.js.map +1 -1
  29. package/es5/framework.js +1 -1
  30. package/es5/mixins/activatable/index.js +2 -1
  31. package/es5/mixins/activatable/index.js.map +1 -1
  32. package/es5/mixins/bootable/index.js +1 -2
  33. package/es5/mixins/bootable/index.js.map +1 -1
  34. package/es5/mixins/mouse/index.js +10 -5
  35. package/es5/mixins/mouse/index.js.map +1 -1
  36. package/es5/mixins/selectable/index.js +3 -0
  37. package/es5/mixins/selectable/index.js.map +1 -1
  38. package/lib/components/VBadge/VBadge.js +14 -13
  39. package/lib/components/VBadge/VBadge.js.map +1 -1
  40. package/lib/components/VBtn/VBtn.js +18 -19
  41. package/lib/components/VBtn/VBtn.js.map +1 -1
  42. package/lib/components/VColorPicker/VColorPicker.js +29 -37
  43. package/lib/components/VColorPicker/VColorPicker.js.map +1 -1
  44. package/lib/components/VColorPicker/VColorPickerCanvas.js +41 -43
  45. package/lib/components/VColorPicker/VColorPickerCanvas.js.map +1 -1
  46. package/lib/components/VColorPicker/VColorPickerEdit.js +25 -31
  47. package/lib/components/VColorPicker/VColorPickerEdit.js.map +1 -1
  48. package/lib/components/VColorPicker/VColorPickerPreview.js +45 -32
  49. package/lib/components/VColorPicker/VColorPickerPreview.js.map +1 -1
  50. package/lib/components/VColorPicker/VColorPickerSwatches.js +15 -9
  51. package/lib/components/VColorPicker/VColorPickerSwatches.js.map +1 -1
  52. package/lib/components/VDataTable/VDataTable.js +3 -4
  53. package/lib/components/VDataTable/VDataTable.js.map +1 -1
  54. package/lib/components/VInput/VInput.js +16 -4
  55. package/lib/components/VInput/VInput.js.map +1 -1
  56. package/lib/components/VSelect/VSelectList.js +2 -1
  57. package/lib/components/VSelect/VSelectList.js.map +1 -1
  58. package/lib/components/VSlider/VSlider.js +26 -21
  59. package/lib/components/VSlider/VSlider.js.map +1 -1
  60. package/lib/components/VTooltip/VTooltip.js +6 -9
  61. package/lib/components/VTooltip/VTooltip.js.map +1 -1
  62. package/lib/framework.js +1 -1
  63. package/lib/mixins/activatable/index.js +2 -1
  64. package/lib/mixins/activatable/index.js.map +1 -1
  65. package/lib/mixins/bootable/index.js +2 -4
  66. package/lib/mixins/bootable/index.js.map +1 -1
  67. package/lib/mixins/mouse/index.js +9 -5
  68. package/lib/mixins/mouse/index.js.map +1 -1
  69. package/lib/mixins/selectable/index.js +4 -0
  70. package/lib/mixins/selectable/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/components/VBadge/VBadge.ts +24 -25
  73. package/src/components/VBadge/__tests__/VBadge.spec.ts +47 -30
  74. package/src/components/VBadge/__tests__/__snapshots__/VBadge.spec.ts.snap +5 -5
  75. package/src/components/VBtn/VBtn.ts +18 -16
  76. package/src/components/VBtn/__tests__/VBtn.spec.ts +257 -242
  77. package/src/components/VBtn/__tests__/__snapshots__/VBtn.spec.ts.snap +13 -73
  78. package/src/components/VColorPicker/VColorPicker.ts +32 -35
  79. package/src/components/VColorPicker/VColorPickerCanvas.ts +44 -37
  80. package/src/components/VColorPicker/VColorPickerEdit.ts +37 -35
  81. package/src/components/VColorPicker/VColorPickerPreview.ts +48 -28
  82. package/src/components/VColorPicker/VColorPickerSwatches.ts +23 -12
  83. package/src/components/VColorPicker/__tests__/VColorPicker.spec.ts +47 -47
  84. package/src/components/VColorPicker/__tests__/VColorPickerCanvas.spec.ts +15 -13
  85. package/src/components/VColorPicker/__tests__/VColorPickerEdit.spec.ts +52 -50
  86. package/src/components/VColorPicker/__tests__/VColorPickerPreview.spec.ts +101 -30
  87. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPicker.spec.ts.snap +200 -157
  88. package/src/components/VColorPicker/__tests__/__snapshots__/VColorPickerEdit.spec.ts.snap +28 -11
  89. package/src/components/VDataTable/VDataTable.ts +3 -3
  90. package/src/components/VInput/VInput.ts +12 -2
  91. package/src/components/VInput/__tests__/VInput.spec.ts +170 -234
  92. package/src/components/VInput/__tests__/__snapshots__/VInput.spec.ts.snap +50 -101
  93. package/src/components/VSelect/VSelectList.ts +1 -0
  94. package/src/components/VSkeletonLoader/__tests__/VSkeletonLoader.spec.ts +22 -15
  95. package/src/components/VSkeletonLoader/__tests__/__snapshots__/VSkeletonLoader.spec.ts.snap +60 -60
  96. package/src/components/VSlider/VSlider.ts +43 -27
  97. package/src/components/VSlider/__tests__/VSlider.spec.ts +188 -286
  98. package/src/components/VSlider/__tests__/__snapshots__/VSlider.spec.ts.snap +157 -246
  99. package/src/components/VTabs/__tests__/VTab.spec.ts +3 -3
  100. package/src/components/VTabs/__tests__/VTabsBar.spec.ts +2 -2
  101. package/src/components/VTooltip/VTooltip.ts +20 -20
  102. package/src/components/VTooltip/__tests__/VTooltip.spec.ts +60 -75
  103. package/src/mixins/activatable/index.ts +2 -1
  104. package/src/mixins/bootable/__tests__/bootable.spec.ts +17 -11
  105. package/src/mixins/bootable/index.ts +4 -3
  106. package/src/mixins/mouse/__tests__/mouse.spec.ts +54 -40
  107. package/src/mixins/mouse/index.ts +10 -6
  108. package/src/mixins/selectable/index.ts +4 -0
@@ -4,9 +4,9 @@ import VTab from '../VTab'
4
4
  // Utilities
5
5
  import {
6
6
  mount,
7
- RouterLinkStub,
8
7
  VueWrapper,
9
8
  } from '@vue/test-utils'
9
+ import { Vue3RouterLinkStub } from '../../../../test/util/stubs'
10
10
 
11
11
  describe('VTab.ts', () => {
12
12
  type Instance = InstanceType<typeof VTab>
@@ -38,7 +38,7 @@ describe('VTab.ts', () => {
38
38
  },
39
39
  },
40
40
  stubs: {
41
- 'router-link': RouterLinkStub,
41
+ 'router-link': Vue3RouterLinkStub,
42
42
  },
43
43
  },
44
44
  })
@@ -63,7 +63,7 @@ describe('VTab.ts', () => {
63
63
  $route: { path: '/' },
64
64
  },
65
65
  stubs: {
66
- 'router-link': RouterLinkStub,
66
+ 'router-link': Vue3RouterLinkStub,
67
67
  },
68
68
  },
69
69
  })
@@ -5,9 +5,9 @@ import VTabsBar from '../VTabsBar'
5
5
  // Utilities
6
6
  import {
7
7
  mount,
8
- RouterLinkStub,
9
8
  VueWrapper,
10
9
  } from '@vue/test-utils'
10
+ import { Vue3RouterLinkStub } from '../../../../test/util/stubs'
11
11
  import { h, nextTick } from 'vue'
12
12
 
13
13
  describe('VTabsBar.ts', () => {
@@ -21,7 +21,7 @@ describe('VTabsBar.ts', () => {
21
21
  warnHandler: () => {}, // Подавляем предупреждения Vue
22
22
  },
23
23
  stubs: {
24
- RouterLink: RouterLinkStub,
24
+ RouterLink: Vue3RouterLinkStub,
25
25
  },
26
26
  mocks: {
27
27
  $vuetify: {
@@ -1,4 +1,4 @@
1
- import {h, Transition} from 'vue'
1
+ import { h, Transition, vShow, withDirectives, VNode } from 'vue'
2
2
  import './VTooltip.sass'
3
3
 
4
4
  // Mixins
@@ -13,7 +13,6 @@ import { convertToUnit, keyCodes, getSlotType } from '../../util/helpers'
13
13
  import { consoleError } from '../../util/console'
14
14
 
15
15
  // Types
16
- import { VNode } from 'vue'
17
16
  import mixins from '../../util/mixins'
18
17
 
19
18
  /* @vue/component */
@@ -137,7 +136,7 @@ export default mixins(Colorable, Delayable, Dependent, Menuable).extend({
137
136
 
138
137
  beforeMount () {
139
138
  this.$nextTick(() => {
140
- this.value && this.callActivate()
139
+ this.modelValue && this.callActivate()
141
140
  })
142
141
  },
143
142
 
@@ -197,23 +196,24 @@ export default mixins(Colorable, Delayable, Dependent, Menuable).extend({
197
196
  }, [content])
198
197
  },
199
198
  genContent () {
200
- return h(
201
- 'div',
202
- this.setBackgroundColor(this.color, {
203
- class: ['v-tooltip__content', {
204
- [this.contentClass]: true,
205
- menuable__content__active: this.isActive,
206
- 'v-tooltip__content--fixed': this.activatorFixed,
207
- }],
208
- style: this.styles,
209
- attrs: this.getScopeIdAttrs(),
210
- directives: [{
211
- name: 'show',
212
- value: this.isContentActive,
213
- }],
214
- ref: 'content',
215
- }),
216
- this.getContentSlot()
199
+ return withDirectives(
200
+ h(
201
+ 'div',
202
+ this.setBackgroundColor(this.color, {
203
+ class: ['v-tooltip__content', {
204
+ [this.contentClass]: true,
205
+ menuable__content__active: this.isActive,
206
+ 'v-tooltip__content--fixed': this.activatorFixed,
207
+ }],
208
+ style: this.styles,
209
+ attrs: this.getScopeIdAttrs(),
210
+ ref: 'content',
211
+ }),
212
+ this.getContentSlot()
213
+ ),
214
+ [
215
+ [vShow, this.isContentActive]
216
+ ]
217
217
  )
218
218
  },
219
219
  },
@@ -1,13 +1,16 @@
1
1
  import VTooltip from '../VTooltip'
2
2
  import {
3
3
  mount,
4
- MountOptions,
5
- Wrapper,
4
+ enableAutoUnmount,
5
+ VueWrapper,
6
6
  } from '@vue/test-utils'
7
+ import { h } from 'vue'
7
8
 
8
9
  describe('VTooltip', () => {
9
10
  type Instance = InstanceType<typeof VTooltip>
10
- let mountFunction: (options?: MountOptions<Instance>) => Wrapper<Instance>
11
+ let mountFunction: (options?: any) => VueWrapper<Instance>
12
+
13
+ enableAutoUnmount(afterEach)
11
14
 
12
15
  beforeEach(() => {
13
16
  document.body.setAttribute('data-app', 'true')
@@ -19,15 +22,13 @@ describe('VTooltip', () => {
19
22
 
20
23
  it('should render component with top and match snapshot', async () => {
21
24
  const wrapper = mountFunction({
22
- propsData: {
25
+ props: {
23
26
  openDelay: 0,
24
27
  top: true,
25
28
  },
26
- scopedSlots: {
27
- activator: '<span>activator</span>',
28
- },
29
29
  slots: {
30
- default: '<span>content</span>',
30
+ activator: () => h('span', 'activator'),
31
+ default: () => h('span', 'content'),
31
32
  },
32
33
  })
33
34
 
@@ -35,24 +36,21 @@ describe('VTooltip', () => {
35
36
  expect(wrapper.vm.offsetY).toBeTruthy()
36
37
  expect(wrapper.html()).toMatchSnapshot()
37
38
 
38
- wrapper.setProps({
39
- value: true,
39
+ await wrapper.setProps({
40
+ modelValue: true,
40
41
  })
41
- await wrapper.vm.$nextTick()
42
42
  expect(wrapper.html()).toMatchSnapshot()
43
43
  })
44
44
 
45
45
  it('should render component with left and match snapshot', async () => {
46
46
  const wrapper = mountFunction({
47
- propsData: {
47
+ props: {
48
48
  openDelay: 0,
49
49
  left: true,
50
50
  },
51
- scopedSlots: {
52
- activator: '<span>activator</span>',
53
- },
54
51
  slots: {
55
- default: '<span>content</span>',
52
+ activator: () => h('span', 'activator'),
53
+ default: () => h('span', 'content'),
56
54
  },
57
55
  })
58
56
 
@@ -60,24 +58,21 @@ describe('VTooltip', () => {
60
58
  expect(wrapper.vm.offsetY).toBeFalsy()
61
59
  expect(wrapper.html()).toMatchSnapshot()
62
60
 
63
- wrapper.setProps({
64
- value: true,
61
+ await wrapper.setProps({
62
+ modelValue: true,
65
63
  })
66
- await wrapper.vm.$nextTick()
67
64
  expect(wrapper.html()).toMatchSnapshot()
68
65
  })
69
66
 
70
67
  it('should render component with bottom and match snapshot', async () => {
71
68
  const wrapper = mountFunction({
72
- propsData: {
69
+ props: {
73
70
  openDelay: 0,
74
71
  bottom: true,
75
72
  },
76
- scopedSlots: {
77
- activator: '<span>activator</span>',
78
- },
79
73
  slots: {
80
- default: '<span>content</span>',
74
+ activator: () => h('span', 'activator'),
75
+ default: () => h('span', 'content'),
81
76
  },
82
77
  })
83
78
 
@@ -85,24 +80,21 @@ describe('VTooltip', () => {
85
80
  expect(wrapper.vm.offsetY).toBeTruthy()
86
81
  expect(wrapper.html()).toMatchSnapshot()
87
82
 
88
- wrapper.setProps({
89
- value: true,
83
+ await wrapper.setProps({
84
+ modelValue: true,
90
85
  })
91
- await wrapper.vm.$nextTick()
92
86
  expect(wrapper.html()).toMatchSnapshot()
93
87
  })
94
88
 
95
89
  it('should render component with right and match snapshot', async () => {
96
90
  const wrapper = mountFunction({
97
- propsData: {
91
+ props: {
98
92
  openDelay: 0,
99
93
  right: true,
100
94
  },
101
- scopedSlots: {
102
- activator: '<span>activator</span>',
103
- },
104
95
  slots: {
105
- default: '<span>content</span>',
96
+ activator: () => h('span', 'activator'),
97
+ default: () => h('span', 'content'),
106
98
  },
107
99
  })
108
100
 
@@ -110,39 +102,34 @@ describe('VTooltip', () => {
110
102
  expect(wrapper.vm.offsetY).toBeFalsy()
111
103
  expect(wrapper.html()).toMatchSnapshot()
112
104
 
113
- wrapper.setProps({
114
- value: true,
105
+ await wrapper.setProps({
106
+ modelValue: true,
115
107
  })
116
- await wrapper.vm.$nextTick()
117
108
  expect(wrapper.html()).toMatchSnapshot()
118
109
  })
119
110
 
120
111
  it('should render component with custom eager and match snapshot', () => {
121
112
  const wrapper = mountFunction({
122
- propsData: {
113
+ props: {
123
114
  eager: true,
124
115
  },
125
- scopedSlots: {
126
- activator: '<span>activator</span>',
127
- },
128
116
  slots: {
129
- default: '<span>content</span>',
117
+ activator: () => h('span', 'activator'),
118
+ default: () => h('span', 'content'),
130
119
  },
131
120
  })
132
121
 
133
122
  expect(wrapper.html()).toMatchSnapshot()
134
123
  })
135
124
 
136
- it('should render component with value=true and match snapshot', async () => {
125
+ it('should render component with modelValue=true and match snapshot', async () => {
137
126
  const wrapper = mountFunction({
138
- propsData: {
139
- value: true,
140
- },
141
- scopedSlots: {
142
- activator: '<span>activator</span>',
127
+ props: {
128
+ modelValue: true,
143
129
  },
144
130
  slots: {
145
- default: '<span>content</span>',
131
+ activator: () => h('span', 'activator'),
132
+ default: () => h('span', 'content'),
146
133
  },
147
134
  })
148
135
 
@@ -152,16 +139,14 @@ describe('VTooltip', () => {
152
139
 
153
140
  it('should render component with min/max width and match snapshot', async () => {
154
141
  const wrapper = mountFunction({
155
- propsData: {
156
- value: true,
142
+ props: {
143
+ modelValue: true,
157
144
  minWidth: 100,
158
145
  maxWidth: 200,
159
146
  },
160
- scopedSlots: {
161
- activator: '<span>activator</span>',
162
- },
163
147
  slots: {
164
- default: '<span>content</span>',
148
+ activator: () => h('span', 'activator'),
149
+ default: () => h('span', 'content'),
165
150
  },
166
151
  })
167
152
 
@@ -170,7 +155,7 @@ describe('VTooltip', () => {
170
155
 
171
156
  it('should render component with zIndex prop and match snapshot', async () => {
172
157
  const wrapper = mountFunction({
173
- propsData: {
158
+ props: {
174
159
  zIndex: 42,
175
160
  },
176
161
  })
@@ -181,43 +166,45 @@ describe('VTooltip', () => {
181
166
  it('should display tooltip after mouseenter and hide after mouseleave', async () => {
182
167
  jest.useFakeTimers()
183
168
  const wrapper = mountFunction({
184
- propsData: {
169
+ props: {
185
170
  openDelay: 123,
186
171
  closeDelay: 321,
187
172
  },
188
- scopedSlots: {
189
- activator: '<span v-on="props.on" class="activator">activator</span>',
190
- },
191
173
  slots: {
192
- default: '<span class="content">content</span>',
174
+ activator: ({ on }: any) => h('span', { ...on, class: 'activator' }, 'activator'),
175
+ default: () => h('span', { class: 'content' }, 'content'),
193
176
  },
194
177
  })
195
178
 
196
179
  const activator = wrapper.find('.activator')
197
- const cb = jest.fn()
198
- wrapper.vm.$on('input', cb)
199
180
 
200
- activator.trigger('mouseenter')
181
+ await activator.trigger('mouseenter')
201
182
  jest.runAllTimers()
202
183
  await wrapper.vm.$nextTick()
203
- expect((setTimeout as any).mock.calls[0][1]).toBe(123)
204
- expect(cb).toHaveBeenCalledWith(true)
205
184
 
206
- activator.trigger('mouseleave')
185
+ // Check if tooltip became active
186
+ expect(wrapper.vm.isActive).toBe(true)
187
+ expect(wrapper.emitted()['update:modelValue']).toBeTruthy()
188
+ expect(wrapper.emitted()['update:modelValue'][0]).toEqual([true])
189
+
190
+ await activator.trigger('mouseleave')
207
191
  jest.runAllTimers()
208
192
  await wrapper.vm.$nextTick()
209
- expect((setTimeout as any).mock.calls[1][1]).toBe(321)
210
- expect(cb).toHaveBeenCalledWith(false)
193
+
194
+ expect(wrapper.vm.isActive).toBe(false)
195
+ expect(wrapper.emitted()['update:modelValue'][1]).toEqual([false])
196
+
197
+ jest.useRealTimers()
211
198
  })
212
199
 
213
200
  it(`should warn if activator isn't scoped`, () => {
214
201
  mountFunction({
215
- propsData: {
202
+ props: {
216
203
  openDelay: 0,
217
204
  },
218
205
  slots: {
219
- activator: '<span>activator</span>',
220
- default: '<span>content</span>',
206
+ activator: () => h('span', 'activator'),
207
+ default: () => h('span', 'content'),
221
208
  },
222
209
  })
223
210
 
@@ -227,15 +214,13 @@ describe('VTooltip', () => {
227
214
  it(`should open and close`, () => {
228
215
  jest.useFakeTimers()
229
216
  const wrapper = mountFunction({
230
- propsData: {
217
+ props: {
231
218
  openDelay: 0,
232
219
  closeDelay: 0,
233
220
  },
234
- scopedSlots: {
235
- activator: '<span v-on="props.on" class="activator">activator</span>',
236
- },
237
221
  slots: {
238
- default: '<span class="content">content</span>',
222
+ activator: ({ on }: any) => h('span', { ...on, class: 'activator' }, 'activator'),
223
+ default: () => h('span', { class: 'content' }, 'content'),
239
224
  },
240
225
  })
241
226
 
@@ -92,7 +92,8 @@ export default baseMixins.extend({
92
92
  attrs: {
93
93
  ...this.genActivatorListeners(),
94
94
  ...this.genActivatorAttributes(),
95
- }
95
+ },
96
+ on: this.genActivatorListeners()
96
97
  })) || []
97
98
 
98
99
  node = Array.isArray(node) ? node : [node]
@@ -4,18 +4,22 @@ import Bootable from '../index'
4
4
  // Utilities
5
5
  import {
6
6
  mount,
7
- Wrapper,
7
+ enableAutoUnmount,
8
+ VueWrapper,
8
9
  } from '@vue/test-utils'
10
+ import { h, nextTick, Comment } from 'vue'
9
11
 
10
12
  describe('Bootable.ts', () => {
11
13
  type Instance = InstanceType<typeof Bootable>
12
- let mountFunction: (options?: object) => Wrapper<Instance>
14
+ let mountFunction: (options?: object) => VueWrapper<Instance>
15
+
16
+ enableAutoUnmount(afterEach)
13
17
 
14
18
  beforeEach(() => {
15
19
  mountFunction = (options = {}) => {
16
20
  return mount({
17
21
  mixins: [Bootable],
18
- render: h => h('div'),
22
+ render: () => h('div'),
19
23
  }, {
20
24
  ...options,
21
25
  })
@@ -31,13 +35,13 @@ describe('Bootable.ts', () => {
31
35
 
32
36
  expect(wrapper.vm.isBooted).toBe(false)
33
37
  wrapper.vm.isActive = true
34
- await wrapper.vm.$nextTick()
38
+ await nextTick()
35
39
  expect(wrapper.vm.isBooted).toBe(true)
36
40
  })
37
41
 
38
42
  it('should return lazy content', async () => {
39
43
  const wrapper = mountFunction({
40
- propsData: {
44
+ props: {
41
45
  eager: true,
42
46
  },
43
47
  })
@@ -50,18 +54,20 @@ describe('Bootable.ts', () => {
50
54
  }),
51
55
  })
52
56
 
53
- expect(wrapperLazy.vm.showLazyContent(() => 'content')).toMatchObject([{ isComment: true }])
57
+ const lazyResult = wrapperLazy.vm.showLazyContent(() => 'content')
58
+ expect(Array.isArray(lazyResult)).toBe(true)
59
+ expect(lazyResult[0].type).toBe(Comment)
54
60
  wrapperLazy.vm.isActive = true
55
- await wrapper.vm.$nextTick()
61
+ await nextTick()
56
62
  expect(wrapperLazy.vm.showLazyContent(() => 'content')).toBe('content')
57
63
  wrapperLazy.vm.isActive = false
58
- await wrapper.vm.$nextTick()
64
+ await nextTick()
59
65
  expect(wrapperLazy.vm.showLazyContent(() => 'content')).toBe('content')
60
66
  })
61
67
 
62
68
  it('should show if lazy and active at boot', async () => {
63
69
  const wrapper = mountFunction({
64
- propsData: {
70
+ props: {
65
71
  eager: true,
66
72
  },
67
73
  })
@@ -77,8 +83,8 @@ describe('Bootable.ts', () => {
77
83
  expect(wrapper.vm.isActive).toBe(false)
78
84
  expect(wrapper.vm.isBooted).toBe(false)
79
85
 
80
- wrapper.setData({ isActive: true })
81
- await wrapper.vm.$nextTick()
86
+ wrapper.vm.isActive = true
87
+ await nextTick()
82
88
  expect(wrapper.vm.isBooted).toBe(true)
83
89
  })
84
90
  })
@@ -1,9 +1,10 @@
1
1
  // Utilities
2
2
  import { removed } from '../../util/console'
3
- import {h} from 'vue'
4
3
 
5
4
  // Types
6
- import { defineComponent, VNode, App } from 'vue'
5
+ import type { VNode, App } from 'vue'
6
+
7
+ import { defineComponent, h, Comment } from 'vue'
7
8
  interface Toggleable extends App {
8
9
  isActive?: boolean
9
10
  }
@@ -49,7 +50,7 @@ export default defineComponent({
49
50
 
50
51
  methods: {
51
52
  showLazyContent (content?: () => VNode[]): VNode[] {
52
- return (this.hasContent && content) ? content() : [h()]
53
+ return (this.hasContent && content) ? content() : [h(Comment)]
53
54
  },
54
55
  },
55
56
  })
@@ -2,89 +2,103 @@ import Mouse from '../index'
2
2
 
3
3
  import {
4
4
  mount,
5
- Wrapper,
6
- MountOptions,
5
+ VueWrapper,
6
+ MountingOptions,
7
7
  } from '@vue/test-utils'
8
- import { ExtractVue } from '../../../util/mixins'
8
+ import { ComponentPublicInstance, h, defineComponent } from 'vue'
9
9
 
10
- const Mock = Mouse.extend({
11
- render: h => h('div'),
10
+ const Mock = defineComponent({
11
+ mixins: [Mouse],
12
+ render: () => h('div'),
12
13
  })
13
14
 
14
15
  describe('mouse.ts', () => {
15
- type Instance = ExtractVue<typeof Mock>
16
- let mountFunction: (options?: MountOptions<Instance>) => Wrapper<Instance>
16
+ type Instance = ComponentPublicInstance & InstanceType<typeof Mock>
17
+ let mountFunction: (options?: MountingOptions<Instance>) => VueWrapper<Instance>
18
+
17
19
  beforeEach(() => {
18
- mountFunction = (options?: MountOptions<Instance>) => {
20
+ mountFunction = (options?: MountingOptions<Instance>) => {
19
21
  return mount(Mock, options)
20
22
  }
21
23
  })
22
24
 
23
25
  it('should generate mouse event handlers', async () => {
24
- const noop = e => e
26
+ const noop = (e: any) => e
25
27
  const wrapper = mount(Mock, {
26
- listeners: {
27
- click: noop,
28
+ attrs: {
29
+ onClick: noop,
28
30
  },
29
31
  })
30
32
 
31
- expect(typeof wrapper.vm.getMouseEventHandlers({ click: { event: 'click' } }, noop).click).toBe('function')
33
+ const handlers = wrapper.vm.getMouseEventHandlers({ click: { event: 'click' } }, noop)
34
+ expect(typeof handlers.click).toBe('function')
32
35
  })
33
36
 
34
37
  it('should generate default mouse event handlers', async () => {
35
- const noop = e => e
38
+ const noop = (e: any) => e
36
39
  const wrapper = mount(Mock, {
37
- listeners: {
38
- 'click:foo': noop,
40
+ attrs: {
41
+ 'onClick:foo': noop,
39
42
  },
40
43
  })
41
44
 
42
- expect(typeof wrapper.vm.getDefaultMouseEventHandlers(':foo', noop).click).toBe('function')
43
- expect(Object.keys(typeof wrapper.vm.getDefaultMouseEventHandlers('', noop))).toHaveLength(6)
45
+ const handlers = wrapper.vm.getDefaultMouseEventHandlers(':foo', noop)
46
+ // Для события click с суффиксом :foo, ключ будет 'click'
47
+ expect(typeof handlers.click).toBe('function')
48
+
49
+ // Тест для пустого суффикса
50
+ const wrapper2 = mount(Mock, {
51
+ attrs: {
52
+ onClick: noop,
53
+ onMouseenter: noop,
54
+ onMouseleave: noop,
55
+ onMousedown: noop,
56
+ onMouseup: noop,
57
+ onMousemove: noop,
58
+ },
59
+ })
60
+ const emptySuffixHandlers = wrapper2.vm.getDefaultMouseEventHandlers('', noop)
61
+ expect(Object.keys(emptySuffixHandlers)).toHaveLength(6)
44
62
  })
45
63
 
46
64
  it('should emit events', async () => {
47
- const fn = jest.fn()
48
65
  const wrapper = mount(Mock, {
49
- listeners: {
50
- click: fn,
66
+ attrs: {
67
+ onClick: () => {},
51
68
  },
52
69
  })
53
70
 
54
- const { click } = wrapper.vm.getMouseEventHandlers({ click: { event: 'click' } }, () => {})
71
+ const handlers = wrapper.vm.getMouseEventHandlers({ click: { event: 'click' } }, () => ({}))
72
+ const click = handlers.click
55
73
  Array.isArray(click) ? click[0](null) : click(null)
56
- expect(fn).toHaveBeenCalledTimes(1)
74
+ expect(wrapper.emitted()).toBeTruthy()
57
75
  })
58
76
 
59
77
  it('should handle prevent modifier', async () => {
60
- const fn = jest.fn()
61
78
  const wrapper = mount(Mock, {
62
- listeners: {
63
- click: fn,
79
+ attrs: {
80
+ onClick: () => {},
64
81
  },
65
82
  })
66
- const event = { preventDefault: () => {} }
67
- const spy = jest.spyOn(event, 'preventDefault')
83
+ const event = { preventDefault: jest.fn() } as unknown as MouseEvent
68
84
 
69
- const { click } = wrapper.vm.getMouseEventHandlers({ click: { event: 'click', prevent: true } }, () => {})
70
- Array.isArray(click) ? click[0](event as MouseEvent) : click(event as MouseEvent)
71
- expect(fn).toHaveBeenCalledTimes(1)
72
- expect(spy).toHaveBeenCalledTimes(1)
85
+ const handlers = wrapper.vm.getMouseEventHandlers({ click: { event: 'click', prevent: true } }, () => ({}))
86
+ const click = handlers.click
87
+ Array.isArray(click) ? click[0](event) : click(event)
88
+ expect(event.preventDefault).toHaveBeenCalledTimes(1)
73
89
  })
74
90
 
75
91
  it('should handle stop modifier', async () => {
76
- const fn = jest.fn()
77
92
  const wrapper = mount(Mock, {
78
- listeners: {
79
- click: fn,
93
+ attrs: {
94
+ onClick: () => {},
80
95
  },
81
96
  })
82
- const event = { stopPropagation: () => {} }
83
- const spy = jest.spyOn(event, 'stopPropagation')
97
+ const event = { stopPropagation: jest.fn() } as unknown as MouseEvent
84
98
 
85
- const { click } = wrapper.vm.getMouseEventHandlers({ click: { event: 'click', stop: true } }, () => {})
86
- Array.isArray(click) ? click[0](event as MouseEvent) : click(event as MouseEvent)
87
- expect(fn).toHaveBeenCalledTimes(1)
88
- expect(spy).toHaveBeenCalledTimes(1)
99
+ const handlers = wrapper.vm.getMouseEventHandlers({ click: { event: 'click', stop: true } }, () => ({}))
100
+ const click = handlers.click
101
+ Array.isArray(click) ? click[0](event) : click(event)
102
+ expect(event.stopPropagation).toHaveBeenCalledTimes(1)
89
103
  })
90
104
  })