@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.
- package/dist/vuetify.js +214 -84
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VOverlay/VOverlay.js +2 -3
- package/es5/components/VOverlay/VOverlay.js.map +1 -1
- package/es5/components/VProgressCircular/VProgressCircular.js +5 -3
- package/es5/components/VProgressCircular/VProgressCircular.js.map +1 -1
- package/es5/components/VProgressLinear/VProgressLinear.js +41 -19
- package/es5/components/VProgressLinear/VProgressLinear.js.map +1 -1
- package/es5/components/VTabs/VTabs.js +1 -1
- package/es5/components/VTabs/VTabs.js.map +1 -1
- package/es5/components/VTabs/VTabsBar.js.map +1 -1
- package/es5/components/VVirtualScroll/VVirtualScroll.js +15 -16
- package/es5/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/es5/components/VWindow/VWindow.js +13 -5
- package/es5/components/VWindow/VWindow.js.map +1 -1
- package/es5/components/VWindow/VWindowItem.js +9 -5
- package/es5/components/VWindow/VWindowItem.js.map +1 -1
- package/es5/framework.js +1 -1
- package/es5/install.js +10 -33
- package/es5/install.js.map +1 -1
- package/es5/mixins/detachable/index.js +2 -3
- package/es5/mixins/detachable/index.js.map +1 -1
- package/es5/mixins/overlayable/index.js.map +1 -1
- package/es5/util/helpers.js +44 -0
- package/es5/util/helpers.js.map +1 -1
- package/es5/util/legacyEventsMixin.js +48 -0
- package/es5/util/legacyEventsMixin.js.map +1 -0
- package/lib/components/VOverlay/VOverlay.js +1 -2
- package/lib/components/VOverlay/VOverlay.js.map +1 -1
- package/lib/components/VProgressCircular/VProgressCircular.js +5 -3
- package/lib/components/VProgressCircular/VProgressCircular.js.map +1 -1
- package/lib/components/VProgressLinear/VProgressLinear.js +35 -17
- package/lib/components/VProgressLinear/VProgressLinear.js.map +1 -1
- package/lib/components/VTabs/VTabs.js +1 -1
- package/lib/components/VTabs/VTabs.js.map +1 -1
- package/lib/components/VTabs/VTabsBar.js.map +1 -1
- package/lib/components/VVirtualScroll/VVirtualScroll.js +8 -11
- package/lib/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/lib/components/VWindow/VWindow.js +7 -3
- package/lib/components/VWindow/VWindow.js.map +1 -1
- package/lib/components/VWindow/VWindowItem.js +3 -1
- package/lib/components/VWindow/VWindowItem.js.map +1 -1
- package/lib/framework.js +1 -1
- package/lib/install.js +5 -28
- package/lib/install.js.map +1 -1
- package/lib/mixins/detachable/index.js +3 -4
- package/lib/mixins/detachable/index.js.map +1 -1
- package/lib/mixins/overlayable/index.js.map +1 -1
- package/lib/util/helpers.js +42 -0
- package/lib/util/helpers.js.map +1 -1
- package/lib/util/legacyEventsMixin.js +37 -0
- package/lib/util/legacyEventsMixin.js.map +1 -0
- package/package.json +1 -1
- package/src/components/VAvatar/__tests__/VAvatar.spec.ts +72 -10
- package/src/components/VOverlay/VOverlay.ts +1 -1
- package/src/components/VOverlay/__tests__/VOverlay.spec.ts +6 -6
- package/src/components/VProgressCircular/VProgressCircular.ts +6 -5
- package/src/components/VProgressCircular/__tests__/VProgressCircular.spec.ts +28 -21
- package/src/components/VProgressCircular/__tests__/__snapshots__/VProgressCircular.spec.ts.snap +62 -62
- package/src/components/VProgressLinear/VProgressLinear.ts +42 -22
- package/src/components/VProgressLinear/__tests__/VProgressLinear.spec.ts +378 -71
- package/src/components/VProgressLinear/__tests__/__snapshots__/VProgressLinear.spec.ts.snap +53 -79
- package/src/components/VSheet/__tests__/VSheet.spec.ts +5 -5
- package/src/components/VTabs/VTabs.ts +1 -1
- package/src/components/VTabs/VTabsBar.ts +7 -5
- package/src/components/VTabs/__tests__/VTab.spec.ts +48 -37
- package/src/components/VTabs/__tests__/VTabs.spec.ts +134 -79
- package/src/components/VTabs/__tests__/VTabsBar.spec.ts +67 -26
- package/src/components/VTabs/__tests__/VTabsSlider.spec.ts +7 -6
- package/src/components/VTabs/__tests__/__snapshots__/VTabs.spec.ts.snap +1 -3
- package/src/components/VVirtualScroll/VVirtualScroll.ts +14 -13
- package/src/components/VVirtualScroll/__tests__/VVirtualScroll.spec.ts +26 -19
- package/src/components/VWindow/VWindow.ts +9 -5
- package/src/components/VWindow/VWindowItem.ts +3 -1
- package/src/components/VWindow/__tests__/VWindow.spec.ts +226 -185
- package/src/components/VWindow/__tests__/VWindowItem.spec.ts +162 -132
- package/src/install.ts +10 -32
- package/src/mixins/applicationable/__tests__/applicationable.spec.ts +31 -27
- package/src/mixins/colorable/__tests__/colorable.spec.ts +9 -6
- package/src/mixins/detachable/index.ts +2 -1
- package/src/mixins/elevatable/__tests__/elevatable.spec.ts +14 -13
- package/src/mixins/intersectable/__tests__/intersectable.spec.ts +35 -29
- package/src/mixins/menuable/__tests__/menuable.spec.ts +76 -33
- package/src/mixins/mobile/__tests__/mobile.spec.ts +9 -6
- package/src/mixins/overlayable/__tests__/overlayable.spec.ts +32 -24
- package/src/mixins/overlayable/index.ts +1 -1
- package/src/mixins/proxyable/__tests__/proxyable.spec.ts +18 -17
- package/src/mixins/registrable/__tests__/registrable.spec.ts +31 -0
- package/src/mixins/rippleable/__tests__/rippleable.spec.ts +10 -9
- package/src/mixins/roundable/__tests__/roundable.spec.ts +7 -5
- package/src/mixins/routable/__tests__/routable.spec.ts +60 -52
- package/src/mixins/scrollable/__tests__/scrollable.spec.ts +56 -27
- package/src/mixins/selectable/__tests__/selectable.spec.ts +22 -9
- package/src/util/__tests__/helpers.spec.ts +62 -1
- package/src/util/helpers.ts +42 -1
- package/src/util/legacyEventsMixin.ts +34 -0
|
@@ -1,187 +1,217 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
// Plugins
|
|
5
|
-
import Router from 'vue-router'
|
|
2
|
+
import { h, nextTick } from "vue";
|
|
6
3
|
|
|
7
4
|
// Components
|
|
8
|
-
import VWindow from
|
|
9
|
-
import VWindowItem from
|
|
5
|
+
import VWindow from "../VWindow";
|
|
6
|
+
import VWindowItem from "../VWindowItem";
|
|
10
7
|
|
|
11
8
|
// Utilities
|
|
12
9
|
import {
|
|
13
|
-
createLocalVue,
|
|
14
10
|
mount,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
VueWrapper,
|
|
12
|
+
MountingOptions,
|
|
13
|
+
enableAutoUnmount
|
|
14
|
+
} from "@vue/test-utils";
|
|
15
|
+
import { waitAnimationFrame } from "../../../../test";
|
|
19
16
|
|
|
20
|
-
describe(
|
|
21
|
-
type Instance = InstanceType<typeof VWindowItem
|
|
22
|
-
let mountFunction: (
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
describe("VWindowItem.ts", () => {
|
|
18
|
+
type Instance = InstanceType<typeof VWindowItem>;
|
|
19
|
+
let mountFunction: (
|
|
20
|
+
options?: MountingOptions<Instance>
|
|
21
|
+
) => VueWrapper<Instance>;
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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(
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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(
|
|
58
|
-
expect(
|
|
59
|
-
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
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
|
-
|
|
66
|
-
await
|
|
67
|
-
expect(
|
|
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
|
-
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
77
|
+
itemVm.onAfterTransition();
|
|
78
|
+
expect(windowVm.transitionHeight).toBeUndefined();
|
|
79
|
+
expect(windowVm.isActive).toBeFalsy();
|
|
73
80
|
|
|
74
81
|
// Canceling
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
itemVm.onBeforeTransition();
|
|
83
|
+
itemVm.onEnter(el);
|
|
84
|
+
itemVm.onTransitionCancelled();
|
|
78
85
|
|
|
79
|
-
expect(
|
|
80
|
-
expect(
|
|
86
|
+
expect(itemVm.inTransition).toBeFalsy();
|
|
87
|
+
expect(windowVm.isActive).toBeFalsy();
|
|
81
88
|
|
|
82
89
|
// Normal path.
|
|
83
|
-
|
|
84
|
-
expect(
|
|
85
|
-
|
|
90
|
+
itemVm.onBeforeTransition();
|
|
91
|
+
expect(windowVm.isActive).toBeTruthy();
|
|
92
|
+
itemVm.onAfterTransition();
|
|
86
93
|
|
|
87
|
-
expect(
|
|
88
|
-
})
|
|
94
|
+
expect(windowVm.isActive).toBeFalsy();
|
|
95
|
+
});
|
|
89
96
|
|
|
90
|
-
it(
|
|
97
|
+
it("should use custom transition", async () => {
|
|
91
98
|
const wrapper = mountFunction({
|
|
92
|
-
|
|
93
|
-
transition:
|
|
94
|
-
reverseTransition:
|
|
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
|
-
|
|
112
|
+
const vm = wrapper.vm as any;
|
|
106
113
|
|
|
107
|
-
|
|
108
|
-
expect(wrapper.vm.computedTransition).toBe('')
|
|
114
|
+
expect(vm.computedTransition).toBe("foo");
|
|
109
115
|
|
|
110
|
-
wrapper.
|
|
111
|
-
|
|
116
|
+
await wrapper.setProps({ transition: false });
|
|
117
|
+
await nextTick();
|
|
118
|
+
// В Vue 3 нужно дождаться обновления computed
|
|
119
|
+
expect(vm.computedTransition).toBe("");
|
|
112
120
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
vm.windowGroup.internalReverse = true;
|
|
122
|
+
await nextTick();
|
|
123
|
+
expect(vm.computedTransition).toBe("bar");
|
|
116
124
|
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
143
|
+
global: {
|
|
144
|
+
config: {
|
|
145
|
+
warnHandler: () => {} // Подавляем предупреждения Vue
|
|
133
146
|
},
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
item.vm
|
|
145
|
-
|
|
146
|
-
expect(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
global: {
|
|
180
|
+
config: {
|
|
181
|
+
warnHandler: () => {} // Подавляем предупреждения Vue
|
|
159
182
|
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
expect(
|
|
171
|
-
|
|
172
|
-
expect(
|
|
173
|
-
expect(
|
|
174
|
-
items[0].
|
|
175
|
-
expect(
|
|
176
|
-
expect(
|
|
177
|
-
items[
|
|
178
|
-
expect(
|
|
179
|
-
expect(
|
|
180
|
-
items[
|
|
181
|
-
expect(
|
|
182
|
-
expect(
|
|
183
|
-
items[2].
|
|
184
|
-
expect(
|
|
185
|
-
expect(
|
|
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
|
-
|
|
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
|
-
|
|
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?:
|
|
7
|
+
let mountFunction: (options?: any) => any
|
|
8
|
+
|
|
11
9
|
beforeEach(() => {
|
|
12
|
-
mountFunction = (options
|
|
13
|
-
|
|
14
|
-
render:
|
|
10
|
+
mountFunction = (options = {}) => {
|
|
11
|
+
const component = defineComponent({
|
|
12
|
+
render: () => h('div'),
|
|
15
13
|
...options,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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
|
-
|
|
59
|
-
expect(
|
|
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
|
-
|
|
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.
|
|
86
|
-
await
|
|
87
|
-
expect(removeApplication
|
|
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
|
-
|
|
5
|
-
|
|
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 =
|
|
10
|
-
|
|
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?:
|
|
16
|
+
let mountFunction: (options?: MountingOptions<Instance>) => VueWrapper<Instance>
|
|
17
|
+
|
|
15
18
|
beforeEach(() => {
|
|
16
|
-
mountFunction = (options?:
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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?:
|
|
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,
|