@dimailn/vuetify 2.7.2-alpha20 → 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 (98) hide show
  1. package/dist/vuetify.js +214 -84
  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/VTabs.js +1 -1
  12. package/es5/components/VTabs/VTabs.js.map +1 -1
  13. package/es5/components/VTabs/VTabsBar.js.map +1 -1
  14. package/es5/components/VVirtualScroll/VVirtualScroll.js +15 -16
  15. package/es5/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
  16. package/es5/components/VWindow/VWindow.js +13 -5
  17. package/es5/components/VWindow/VWindow.js.map +1 -1
  18. package/es5/components/VWindow/VWindowItem.js +9 -5
  19. package/es5/components/VWindow/VWindowItem.js.map +1 -1
  20. package/es5/framework.js +1 -1
  21. package/es5/install.js +10 -33
  22. package/es5/install.js.map +1 -1
  23. package/es5/mixins/detachable/index.js +2 -3
  24. package/es5/mixins/detachable/index.js.map +1 -1
  25. package/es5/mixins/overlayable/index.js.map +1 -1
  26. package/es5/util/helpers.js +44 -0
  27. package/es5/util/helpers.js.map +1 -1
  28. package/es5/util/legacyEventsMixin.js +48 -0
  29. package/es5/util/legacyEventsMixin.js.map +1 -0
  30. package/lib/components/VOverlay/VOverlay.js +1 -2
  31. package/lib/components/VOverlay/VOverlay.js.map +1 -1
  32. package/lib/components/VProgressCircular/VProgressCircular.js +5 -3
  33. package/lib/components/VProgressCircular/VProgressCircular.js.map +1 -1
  34. package/lib/components/VProgressLinear/VProgressLinear.js +35 -17
  35. package/lib/components/VProgressLinear/VProgressLinear.js.map +1 -1
  36. package/lib/components/VTabs/VTabs.js +1 -1
  37. package/lib/components/VTabs/VTabs.js.map +1 -1
  38. package/lib/components/VTabs/VTabsBar.js.map +1 -1
  39. package/lib/components/VVirtualScroll/VVirtualScroll.js +8 -11
  40. package/lib/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
  41. package/lib/components/VWindow/VWindow.js +7 -3
  42. package/lib/components/VWindow/VWindow.js.map +1 -1
  43. package/lib/components/VWindow/VWindowItem.js +3 -1
  44. package/lib/components/VWindow/VWindowItem.js.map +1 -1
  45. package/lib/framework.js +1 -1
  46. package/lib/install.js +5 -28
  47. package/lib/install.js.map +1 -1
  48. package/lib/mixins/detachable/index.js +3 -4
  49. package/lib/mixins/detachable/index.js.map +1 -1
  50. package/lib/mixins/overlayable/index.js.map +1 -1
  51. package/lib/util/helpers.js +42 -0
  52. package/lib/util/helpers.js.map +1 -1
  53. package/lib/util/legacyEventsMixin.js +37 -0
  54. package/lib/util/legacyEventsMixin.js.map +1 -0
  55. package/package.json +1 -1
  56. package/src/components/VAvatar/__tests__/VAvatar.spec.ts +72 -10
  57. package/src/components/VOverlay/VOverlay.ts +1 -1
  58. package/src/components/VOverlay/__tests__/VOverlay.spec.ts +6 -6
  59. package/src/components/VProgressCircular/VProgressCircular.ts +6 -5
  60. package/src/components/VProgressCircular/__tests__/VProgressCircular.spec.ts +28 -21
  61. package/src/components/VProgressCircular/__tests__/__snapshots__/VProgressCircular.spec.ts.snap +62 -62
  62. package/src/components/VProgressLinear/VProgressLinear.ts +42 -22
  63. package/src/components/VProgressLinear/__tests__/VProgressLinear.spec.ts +378 -71
  64. package/src/components/VProgressLinear/__tests__/__snapshots__/VProgressLinear.spec.ts.snap +53 -79
  65. package/src/components/VSheet/__tests__/VSheet.spec.ts +5 -5
  66. package/src/components/VTabs/VTabs.ts +1 -1
  67. package/src/components/VTabs/VTabsBar.ts +7 -5
  68. package/src/components/VTabs/__tests__/VTab.spec.ts +48 -37
  69. package/src/components/VTabs/__tests__/VTabs.spec.ts +134 -79
  70. package/src/components/VTabs/__tests__/VTabsBar.spec.ts +67 -26
  71. package/src/components/VTabs/__tests__/VTabsSlider.spec.ts +7 -6
  72. package/src/components/VTabs/__tests__/__snapshots__/VTabs.spec.ts.snap +1 -3
  73. package/src/components/VVirtualScroll/VVirtualScroll.ts +14 -13
  74. package/src/components/VVirtualScroll/__tests__/VVirtualScroll.spec.ts +26 -19
  75. package/src/components/VWindow/VWindow.ts +9 -5
  76. package/src/components/VWindow/VWindowItem.ts +3 -1
  77. package/src/components/VWindow/__tests__/VWindow.spec.ts +226 -185
  78. package/src/components/VWindow/__tests__/VWindowItem.spec.ts +162 -132
  79. package/src/install.ts +10 -32
  80. package/src/mixins/applicationable/__tests__/applicationable.spec.ts +31 -27
  81. package/src/mixins/colorable/__tests__/colorable.spec.ts +9 -6
  82. package/src/mixins/detachable/index.ts +2 -1
  83. package/src/mixins/elevatable/__tests__/elevatable.spec.ts +14 -13
  84. package/src/mixins/intersectable/__tests__/intersectable.spec.ts +35 -29
  85. package/src/mixins/menuable/__tests__/menuable.spec.ts +76 -33
  86. package/src/mixins/mobile/__tests__/mobile.spec.ts +9 -6
  87. package/src/mixins/overlayable/__tests__/overlayable.spec.ts +32 -24
  88. package/src/mixins/overlayable/index.ts +1 -1
  89. package/src/mixins/proxyable/__tests__/proxyable.spec.ts +18 -17
  90. package/src/mixins/registrable/__tests__/registrable.spec.ts +31 -0
  91. package/src/mixins/rippleable/__tests__/rippleable.spec.ts +10 -9
  92. package/src/mixins/roundable/__tests__/roundable.spec.ts +7 -5
  93. package/src/mixins/routable/__tests__/routable.spec.ts +60 -52
  94. package/src/mixins/scrollable/__tests__/scrollable.spec.ts +56 -27
  95. package/src/mixins/selectable/__tests__/selectable.spec.ts +22 -9
  96. package/src/util/__tests__/helpers.spec.ts +62 -1
  97. package/src/util/helpers.ts +42 -1
  98. package/src/util/legacyEventsMixin.ts +34 -0
@@ -1,187 +1,217 @@
1
1
  // Libraries
2
- import Vue from 'vue'
3
-
4
- // Plugins
5
- import Router from 'vue-router'
2
+ import { h, nextTick } from "vue";
6
3
 
7
4
  // Components
8
- import VWindow from '../VWindow'
9
- import VWindowItem from '../VWindowItem'
5
+ import VWindow from "../VWindow";
6
+ import VWindowItem from "../VWindowItem";
10
7
 
11
8
  // Utilities
12
9
  import {
13
- createLocalVue,
14
10
  mount,
15
- Wrapper,
16
- MountOptions,
17
- } from '@vue/test-utils'
18
- import { waitAnimationFrame } from '../../../../test'
11
+ VueWrapper,
12
+ MountingOptions,
13
+ enableAutoUnmount
14
+ } from "@vue/test-utils";
15
+ import { waitAnimationFrame } from "../../../../test";
19
16
 
20
- describe('VWindowItem.ts', () => {
21
- type Instance = InstanceType<typeof VWindowItem>
22
- let mountFunction: (options?: MountOptions<Instance>) => Wrapper<Instance>
23
- let router: Router
24
- let localVue: typeof Vue
17
+ describe("VWindowItem.ts", () => {
18
+ type Instance = InstanceType<typeof VWindowItem>;
19
+ let mountFunction: (
20
+ options?: MountingOptions<Instance>
21
+ ) => VueWrapper<Instance>;
25
22
 
26
- beforeEach(() => {
27
- router = new Router()
28
- localVue = createLocalVue()
29
- localVue.use(Router)
23
+ // Включаем автоматическое размонтирование после каждого теста
24
+ enableAutoUnmount(afterEach);
30
25
 
26
+ beforeEach(() => {
31
27
  mountFunction = (options = {}) => {
32
28
  return mount(VWindowItem, {
33
- localVue,
34
- router,
35
- ...options,
36
- })
37
- }
38
- })
29
+ global: {
30
+ config: {
31
+ warnHandler: () => {} // Подавляем предупреждения Vue
32
+ }
33
+ },
34
+ ...options
35
+ });
36
+ };
37
+ });
39
38
 
40
39
  // eslint-disable-next-line max-statements
41
- it('should transition content', async () => {
40
+ it("should transition content", async () => {
42
41
  const wrapper = mount(VWindow, {
43
42
  slots: {
44
- default: [VWindowItem],
43
+ default: () => [h(VWindowItem)]
45
44
  },
46
- mocks: {
47
- $vuetify: {
48
- rtl: false,
45
+ global: {
46
+ config: {
47
+ warnHandler: () => {} // Подавляем предупреждения Vue
49
48
  },
50
- },
51
- })
49
+ mocks: {
50
+ $vuetify: {
51
+ rtl: false
52
+ }
53
+ }
54
+ }
55
+ });
56
+
57
+ await waitAnimationFrame();
52
58
 
53
- await waitAnimationFrame()
59
+ const item = wrapper.findComponent(VWindowItem);
60
+ const windowVm = wrapper.vm as any;
61
+ const itemVm = item.vm as any;
54
62
 
55
- const item = wrapper.find(VWindowItem.options)
56
63
  // Before enter
57
- expect(wrapper.vm.isActive).toBeFalsy()
58
- expect(wrapper.vm.transitionHeight).toBeUndefined()
59
- item.vm.onBeforeTransition()
60
- expect(wrapper.vm.isActive).toBeTruthy()
61
- expect(wrapper.vm.transitionHeight).toBe('0px')
64
+ expect(windowVm.isActive).toBeFalsy();
65
+ expect(windowVm.transitionHeight).toBeUndefined();
66
+ itemVm.onBeforeTransition();
67
+ expect(windowVm.isActive).toBeTruthy();
68
+ expect(windowVm.transitionHeight).toBe("0px");
62
69
 
63
70
  // Enter
64
- const el = { clientHeight: 50 }
65
- item.vm.onEnter(el)
66
- await wrapper.vm.$nextTick()
67
- expect(wrapper.vm.transitionHeight).toBe('50px')
71
+ const el = { clientHeight: 50 };
72
+ itemVm.onEnter(el);
73
+ await nextTick();
74
+ expect(windowVm.transitionHeight).toBe("50px");
68
75
 
69
76
  // After enter
70
- item.vm.onAfterTransition()
71
- expect(wrapper.vm.transitionHeight).toBeUndefined()
72
- expect(wrapper.vm.isActive).toBeFalsy()
77
+ itemVm.onAfterTransition();
78
+ expect(windowVm.transitionHeight).toBeUndefined();
79
+ expect(windowVm.isActive).toBeFalsy();
73
80
 
74
81
  // Canceling
75
- item.vm.onBeforeTransition()
76
- item.vm.onEnter(el)
77
- item.vm.onTransitionCancelled()
82
+ itemVm.onBeforeTransition();
83
+ itemVm.onEnter(el);
84
+ itemVm.onTransitionCancelled();
78
85
 
79
- expect(item.vm.inTransition).toBeFalsy()
80
- expect(wrapper.vm.isActive).toBeFalsy()
86
+ expect(itemVm.inTransition).toBeFalsy();
87
+ expect(windowVm.isActive).toBeFalsy();
81
88
 
82
89
  // Normal path.
83
- item.vm.onBeforeTransition()
84
- expect(wrapper.vm.isActive).toBeTruthy()
85
- item.vm.onAfterTransition()
90
+ itemVm.onBeforeTransition();
91
+ expect(windowVm.isActive).toBeTruthy();
92
+ itemVm.onAfterTransition();
86
93
 
87
- expect(wrapper.vm.isActive).toBeFalsy()
88
- })
94
+ expect(windowVm.isActive).toBeFalsy();
95
+ });
89
96
 
90
- it('should use custom transition', () => {
97
+ it("should use custom transition", async () => {
91
98
  const wrapper = mountFunction({
92
- propsData: {
93
- transition: 'foo',
94
- reverseTransition: 'bar',
99
+ props: {
100
+ transition: "foo",
101
+ reverseTransition: "bar"
95
102
  },
96
103
  data: () => ({
97
104
  windowGroup: {
98
105
  internalReverse: false,
99
106
  register: () => {},
100
- unregister: () => {},
101
- },
102
- }),
103
- })
107
+ unregister: () => {}
108
+ }
109
+ })
110
+ });
104
111
 
105
- expect(wrapper.vm.computedTransition).toBe('foo')
112
+ const vm = wrapper.vm as any;
106
113
 
107
- wrapper.setProps({ transition: false })
108
- expect(wrapper.vm.computedTransition).toBe('')
114
+ expect(vm.computedTransition).toBe("foo");
109
115
 
110
- wrapper.vm.windowGroup.internalReverse = true
111
- expect(wrapper.vm.computedTransition).toBe('bar')
116
+ await wrapper.setProps({ transition: false });
117
+ await nextTick();
118
+ // В Vue 3 нужно дождаться обновления computed
119
+ expect(vm.computedTransition).toBe("");
112
120
 
113
- wrapper.setProps({ reverseTransition: false })
114
- expect(wrapper.vm.computedTransition).toBe('')
115
- })
121
+ vm.windowGroup.internalReverse = true;
122
+ await nextTick();
123
+ expect(vm.computedTransition).toBe("bar");
116
124
 
117
- it('should not set initial height if no computedTransition', async () => {
118
- const heightChanged = jest.fn()
125
+ await wrapper.setProps({ reverseTransition: false });
126
+ await nextTick();
127
+ expect(vm.computedTransition).toBe("");
128
+ });
129
+
130
+ it("should not set initial height if no computedTransition", async () => {
131
+ const heightChanged = jest.fn();
119
132
  const wrapper = mount(VWindow, {
120
- propsData: {
133
+ props: {
121
134
  transition: false,
122
- reverseTransition: false,
135
+ reverseTransition: false
123
136
  },
124
137
  watch: {
125
- transitionHeight: heightChanged,
138
+ transitionHeight: heightChanged
126
139
  },
127
140
  slots: {
128
- default: [VWindowItem],
141
+ default: () => [h(VWindowItem)]
129
142
  },
130
- mocks: {
131
- $vuetify: {
132
- rtl: false,
143
+ global: {
144
+ config: {
145
+ warnHandler: () => {} // Подавляем предупреждения Vue
133
146
  },
134
- },
135
- })
136
-
137
- const item = wrapper.find(VWindowItem.options)
138
- expect(wrapper.vm.computedTransition).toBeFalsy()
139
-
140
- item.vm.onBeforeTransition()
141
- expect(wrapper.vm.isActive).toBeTruthy()
142
- expect(heightChanged).toHaveBeenCalledTimes(1)
143
-
144
- item.vm.onEnter(wrapper.$el)
145
- await waitAnimationFrame()
146
- expect(wrapper.vm.isActive).toBeTruthy()
147
-
148
- expect(heightChanged).toHaveBeenCalledTimes(1)
149
- })
150
-
151
- it('should increase and decrease transition count correctly', () => {
147
+ mocks: {
148
+ $vuetify: {
149
+ rtl: false
150
+ }
151
+ }
152
+ }
153
+ });
154
+
155
+ const item = wrapper.findComponent(VWindowItem);
156
+ const windowVm = wrapper.vm as any;
157
+ const itemVm = item.vm as any;
158
+
159
+ expect(windowVm.computedTransition).toBeFalsy();
160
+
161
+ itemVm.onBeforeTransition();
162
+ expect(windowVm.isActive).toBeTruthy();
163
+ // В Vue 3 watch может не срабатывать сразу, поэтому проверяем после nextTick
164
+ await nextTick();
165
+ expect(heightChanged).toHaveBeenCalledTimes(1);
166
+
167
+ itemVm.onEnter(wrapper.element);
168
+ await waitAnimationFrame();
169
+ expect(windowVm.isActive).toBeTruthy();
170
+
171
+ expect(heightChanged).toHaveBeenCalledTimes(1);
172
+ });
173
+
174
+ it("should increase and decrease transition count correctly", () => {
152
175
  const wrapper = mount(VWindow, {
153
176
  slots: {
154
- default: [VWindowItem, VWindowItem, VWindowItem],
177
+ default: () => [h(VWindowItem), h(VWindowItem), h(VWindowItem)]
155
178
  },
156
- mocks: {
157
- $vuetify: {
158
- rtl: false,
179
+ global: {
180
+ config: {
181
+ warnHandler: () => {} // Подавляем предупреждения Vue
159
182
  },
160
- },
161
- })
162
-
163
- const items = wrapper.vm.items
164
- expect(items).toHaveLength(3)
165
-
166
- expect(wrapper.vm.transitionCount).toBe(0)
167
- expect(wrapper.vm.isActive).toBeFalsy()
168
- items[0].onBeforeTransition()
169
- expect(wrapper.vm.transitionCount).toBe(1)
170
- expect(wrapper.vm.isActive).toBeTruthy()
171
- items[1].onBeforeTransition()
172
- expect(wrapper.vm.transitionCount).toBe(2)
173
- expect(wrapper.vm.isActive).toBeTruthy()
174
- items[0].onTransitionCancelled()
175
- expect(wrapper.vm.transitionCount).toBe(1)
176
- expect(wrapper.vm.isActive).toBeTruthy()
177
- items[2].onBeforeTransition()
178
- expect(wrapper.vm.transitionCount).toBe(2)
179
- expect(wrapper.vm.isActive).toBeTruthy()
180
- items[1].onAfterTransition()
181
- expect(wrapper.vm.transitionCount).toBe(1)
182
- expect(wrapper.vm.isActive).toBeTruthy()
183
- items[2].onAfterTransition()
184
- expect(wrapper.vm.transitionCount).toBe(0)
185
- expect(wrapper.vm.isActive).toBeFalsy()
186
- })
187
- })
183
+ mocks: {
184
+ $vuetify: {
185
+ rtl: false
186
+ }
187
+ }
188
+ }
189
+ });
190
+
191
+ const windowVm = wrapper.vm as any;
192
+ const items = windowVm.items as any[];
193
+ expect(items).toHaveLength(3);
194
+
195
+ expect(windowVm.transitionCount).toBe(0);
196
+ expect(windowVm.isActive).toBeFalsy();
197
+ items[0].onBeforeTransition();
198
+ expect(windowVm.transitionCount).toBe(1);
199
+ expect(windowVm.isActive).toBeTruthy();
200
+ items[1].onBeforeTransition();
201
+ expect(windowVm.transitionCount).toBe(2);
202
+ expect(windowVm.isActive).toBeTruthy();
203
+ items[0].onTransitionCancelled();
204
+ expect(windowVm.transitionCount).toBe(1);
205
+ expect(windowVm.isActive).toBeTruthy();
206
+ items[2].onBeforeTransition();
207
+ expect(windowVm.transitionCount).toBe(2);
208
+ expect(windowVm.isActive).toBeTruthy();
209
+ items[1].onAfterTransition();
210
+ expect(windowVm.transitionCount).toBe(1);
211
+ expect(windowVm.isActive).toBeTruthy();
212
+ items[2].onAfterTransition();
213
+ expect(windowVm.transitionCount).toBe(0);
214
+ expect(windowVm.isActive).toBeFalsy();
215
+ });
216
+ });
217
+
package/src/install.ts CHANGED
@@ -1,17 +1,18 @@
1
1
  import { createApp, reactive } from 'vue'
2
2
  import { VuetifyUseOptions } from 'vuetify/types'
3
3
  import { consoleError } from './util/console'
4
+ import { legacyEventsMixin } from './util/legacyEventsMixin'
4
5
 
5
6
  export function install (Vue: ReturnType<typeof createApp>, args: VuetifyUseOptions = {}) {
6
7
  // if ((install as any).installed) return
7
8
  // (install as any).installed = true
8
9
 
9
- // if (OurVue !== Vue) {
10
- // consoleError(`Multiple instances of Vue detected
11
- // See https://github.com/vuetifyjs/vuetify/issues/4068
10
+ // if (OurVue !== Vue) {
11
+ // consoleError(`Multiple instances of Vue detected
12
+ // See https://github.com/vuetifyjs/vuetify/issues/4068
12
13
 
13
- // If you're seeing "$attrs is readonly", it's caused by this`)
14
- // }
14
+ // If you're seeing "$attrs is readonly", it's caused by this`)
15
+ // }
15
16
 
16
17
  const components = args.components || {}
17
18
  const directives = args.directives || {}
@@ -22,7 +23,6 @@ export function install (Vue: ReturnType<typeof createApp>, args: VuetifyUseOpti
22
23
  Vue.directive(name, directive)
23
24
  }
24
25
 
25
-
26
26
  (function registerComponents (components: any) {
27
27
  if (components) {
28
28
  for (const key in components) {
@@ -43,6 +43,9 @@ export function install (Vue: ReturnType<typeof createApp>, args: VuetifyUseOpti
43
43
  Vue.$_vuetify_installed = true
44
44
 
45
45
  Vue.mixin({
46
+ computed: {
47
+ ...legacyEventsMixin.computed,
48
+ },
46
49
  beforeCreate () {
47
50
  const options = this.$options as any
48
51
 
@@ -70,32 +73,7 @@ export function install (Vue: ReturnType<typeof createApp>, args: VuetifyUseOpti
70
73
  }
71
74
  },
72
75
  methods: {
73
- $emitLegacy(eventName, args) {
74
- if(!this.eventsLegacy || !this.eventsLegacy[eventName]) return
75
-
76
-
77
- this.eventsLegacy[eventName].forEach(listener => listener(args))
78
- },
79
- $on(eventName, listener) {
80
- this.eventsLegacy ||= {}
81
- this.eventsLegacy[eventName] ||= []
82
- this.eventsLegacy[eventName].push(listener)
83
- // console.warn("$on is not available")
84
- },
85
- $off(eventName, listener) {
86
- this.eventsLegacy[eventName] = this.eventsLegacy[eventName].filter(_listener => _listener !== listener)
87
- // console.warn('$off is not available')
88
- }
76
+ ...legacyEventsMixin.methods,
89
77
  },
90
- computed: {
91
- $listeners() {
92
- const names = Object.keys(this.$attrs).filter(name => name.startsWith('on'))
93
-
94
- return names.reduce((listeners, name) => {
95
- listeners[name] = this.$attrs[name]
96
- return listeners
97
- }, {})
98
- }
99
- }
100
78
  })
101
79
  }
@@ -1,22 +1,24 @@
1
- import {
2
- mount,
3
- Wrapper,
4
- } from '@vue/test-utils'
1
+ import { mount } from '@vue/test-utils'
2
+ import { h, defineComponent } from 'vue'
5
3
  import Applicationable from '../'
6
- import { ComponentOptions } from 'vue'
7
4
  import { Application } from '../../../services/application'
8
5
 
9
6
  describe('applicationable.js', () => {
10
- let mountFunction: (options?: ComponentOptions<any>) => Wrapper<any>
7
+ let mountFunction: (options?: any) => any
8
+
11
9
  beforeEach(() => {
12
- mountFunction = (options?: ComponentOptions<any>) => {
13
- return mount({
14
- render: h => h('div'),
10
+ mountFunction = (options = {}) => {
11
+ const component = defineComponent({
12
+ render: () => h('div'),
15
13
  ...options,
16
- }, {
17
- mocks: {
18
- $vuetify: {
19
- application: new Application(),
14
+ })
15
+
16
+ return mount(component, {
17
+ global: {
18
+ mocks: {
19
+ $vuetify: {
20
+ application: new Application(),
21
+ },
20
22
  },
21
23
  },
22
24
  })
@@ -33,9 +35,9 @@ describe('applicationable.js', () => {
33
35
  methods: { updateApplication },
34
36
  })
35
37
 
36
- wrapper.setProps({ app: true })
38
+ await wrapper.setProps({ app: true })
37
39
  await wrapper.vm.$nextTick()
38
- expect(updateApplication.mock.calls).toHaveLength(1)
40
+ expect(updateApplication).toHaveBeenCalledTimes(1)
39
41
  })
40
42
 
41
43
  it('should update application on app prop change', async () => {
@@ -49,14 +51,15 @@ describe('applicationable.js', () => {
49
51
  methods: { updateApplication, removeApplication },
50
52
  })
51
53
 
52
- wrapper.setProps({ app: true })
54
+ await wrapper.setProps({ app: true })
53
55
  await wrapper.vm.$nextTick()
54
- wrapper.setProps({ app: false })
56
+ await wrapper.setProps({ app: false })
55
57
  await wrapper.vm.$nextTick()
56
- wrapper.setProps({ app: true })
58
+ await wrapper.setProps({ app: true })
57
59
  await wrapper.vm.$nextTick()
58
- expect(updateApplication.mock.calls).toHaveLength(2)
59
- expect(removeApplication.mock.calls).toHaveLength(1)
60
+
61
+ expect(updateApplication).toHaveBeenCalledTimes(2)
62
+ expect(removeApplication).toHaveBeenCalledTimes(1)
60
63
  })
61
64
 
62
65
  it('should bind watchers passed through factory', () => {
@@ -68,7 +71,8 @@ describe('applicationable.js', () => {
68
71
  mixins: [Applicationable(null, ['foo', 'bar'])],
69
72
  })
70
73
 
71
- expect(wrapper.vm._scope.effects).toHaveLength(6)
74
+ // В Vue 3 структура реактивности изменилась
75
+ expect(wrapper.vm.$.scope?.effects?.length || 0).toBeGreaterThan(0)
72
76
  })
73
77
 
74
78
  it('should call to remove application on destroy', async () => {
@@ -81,10 +85,10 @@ describe('applicationable.js', () => {
81
85
  methods: { removeApplication },
82
86
  })
83
87
 
84
- wrapper.setProps({ app: true })
85
- wrapper.destroy()
86
- await wrapper.vm.$nextTick()
87
- expect(removeApplication.mock.calls).toHaveLength(1)
88
+ await wrapper.setProps({ app: true })
89
+ wrapper.unmount()
90
+ await new Promise(resolve => setTimeout(resolve, 0))
91
+ expect(removeApplication).toHaveBeenCalledTimes(1)
88
92
  })
89
93
 
90
94
  it('should update application with dynamic property', async () => {
@@ -102,7 +106,7 @@ describe('applicationable.js', () => {
102
106
  },
103
107
  })
104
108
 
105
- wrapper.setProps({ app: true })
109
+ await wrapper.setProps({ app: true })
106
110
  await wrapper.vm.$nextTick()
107
111
  expect(wrapper.vm.$vuetify.application.top).toBe(30)
108
112
  })
@@ -117,7 +121,7 @@ describe('applicationable.js', () => {
117
121
  },
118
122
  })
119
123
 
120
- wrapper.setProps({ app: true })
124
+ await wrapper.setProps({ app: true })
121
125
  await wrapper.vm.$nextTick()
122
126
  expect(wrapper.vm.$vuetify.application.footer).toBe(30)
123
127
  wrapper.vm.removeApplication()
@@ -1,19 +1,22 @@
1
1
  import Colorable from '../'
2
2
  import {
3
3
  mount,
4
- MountOptions,
5
- Wrapper,
4
+ MountingOptions,
5
+ VueWrapper,
6
6
  } from '@vue/test-utils'
7
+ import { defineComponent } from 'vue'
7
8
 
8
9
  describe('colorable.ts', () => {
9
- const Mock = Colorable.extend({
10
- render: h => h('div'),
10
+ const Mock = defineComponent({
11
+ mixins: [Colorable],
12
+ render: () => null,
11
13
  })
12
14
 
13
15
  type Instance = InstanceType<typeof Mock>
14
- let mountFunction: (options?: MountOptions<Instance>) => Wrapper<Instance>
16
+ let mountFunction: (options?: MountingOptions<Instance>) => VueWrapper<Instance>
17
+
15
18
  beforeEach(() => {
16
- mountFunction = (options?: MountOptions<Instance>) => {
19
+ mountFunction = (options?: MountingOptions<Instance>) => {
17
20
  return mount(Mock, options)
18
21
  }
19
22
  })
@@ -126,7 +126,8 @@ export default mixins<options &
126
126
 
127
127
  methods: {
128
128
  getScopeIdAttrs () {
129
- const scopeId = getObjectValueByPath(this.$vnode, 'context.$options._scopeId')
129
+ // В Vue 3 $vnode больше не существует, используем современный способ
130
+ const scopeId = this.$options._scopeId || this.$options.__scopeId
130
131
 
131
132
  return scopeId && {
132
133
  [scopeId]: '',
@@ -2,18 +2,19 @@
2
2
  import Elevatable from '../'
3
3
 
4
4
  // Utilities
5
- import {
6
- mount,
7
- Wrapper,
8
- } from '@vue/test-utils'
9
-
10
- const Component = Elevatable.extend({
11
- render: h => h('div'),
5
+ import { mount, VueWrapper, MountingOptions } from '@vue/test-utils'
6
+ import { defineComponent, h } from 'vue'
7
+
8
+ const Component = defineComponent({
9
+ mixins: [Elevatable],
10
+ render () {
11
+ return h('div')
12
+ },
12
13
  })
13
14
 
14
15
  describe('elevatable.ts', () => {
15
- type Instance = InstanceType<typeof Component>
16
- let mountFunction: (options?: object) => Wrapper<Instance>
16
+ type Instance = InstanceType<typeof Component>;
17
+ let mountFunction: (options?: MountingOptions<any>) => VueWrapper<Instance>
17
18
 
18
19
  beforeEach(() => {
19
20
  mountFunction = (options = {}) => {
@@ -23,25 +24,25 @@ describe('elevatable.ts', () => {
23
24
  }
24
25
  })
25
26
 
26
- it('generate elevation classes', () => {
27
+ it('generate elevation classes', async () => {
27
28
  const wrapper = mountFunction()
28
29
 
29
30
  expect(wrapper.vm.computedElevation).toBeUndefined()
30
31
  expect(wrapper.vm.elevationClasses).toEqual({})
31
32
 
32
- wrapper.setProps({ elevation: 1 })
33
+ await wrapper.setProps({ elevation: 1 })
33
34
  expect(wrapper.vm.computedElevation).toBe(1)
34
35
  expect(wrapper.vm.elevationClasses).toEqual({
35
36
  'elevation-1': true,
36
37
  })
37
38
 
38
- wrapper.setProps({ elevation: '12' })
39
+ await wrapper.setProps({ elevation: '12' })
39
40
  expect(wrapper.vm.computedElevation).toBe('12')
40
41
  expect(wrapper.vm.elevationClasses).toEqual({
41
42
  'elevation-12': true,
42
43
  })
43
44
 
44
- wrapper.setProps({ elevation: 0 })
45
+ await wrapper.setProps({ elevation: 0 })
45
46
  expect(wrapper.vm.computedElevation).toBe(0)
46
47
  expect(wrapper.vm.elevationClasses).toEqual({
47
48
  'elevation-0': true,