@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
@@ -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
+
@@ -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
  })
@@ -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,
@@ -1,39 +1,45 @@
1
- import intersectable from '../index'
1
+ import intersectable from "../index";
2
+ import { defineComponent, h } from "vue";
3
+ import { mount, VueWrapper } from "@vue/test-utils";
2
4
 
3
- import {
4
- mount,
5
- Wrapper,
6
- } from '@vue/test-utils'
7
- import { ComponentOptions } from 'vue'
8
-
9
- describe('intersectable.ts', () => {
10
- let mountFunction: (options?: ComponentOptions<any>) => Wrapper<any>
5
+ describe("intersectable.ts", () => {
6
+ let mountFunction: (options?: any) => VueWrapper<any>;
11
7
 
12
8
  beforeEach(() => {
13
- mountFunction = (options?: ComponentOptions<any>) => {
14
- return mount({
15
- render: h => h('div'),
16
- ...options,
17
- })
18
- }
19
- })
20
-
21
- it('should call callbacks when element is intersected', () => {
22
- const callback = jest.fn()
9
+ mountFunction = (options?: any) => {
10
+ return mount(
11
+ defineComponent({
12
+ render: () => h("div"),
13
+ ...options
14
+ })
15
+ );
16
+ };
17
+ });
18
+
19
+ it("should call callbacks when element is intersected", () => {
20
+ const callback = jest.fn();
23
21
 
24
22
  const wrapper = mountFunction({
25
- mixins: [intersectable({ onVisible: ['callback'] })],
26
- methods: { callback },
27
- })
23
+ mixins: [intersectable({ onVisible: ["callback"] })],
24
+ methods: { callback }
25
+ });
28
26
 
29
- expect(callback).not.toHaveBeenCalled()
27
+ expect(callback).not.toHaveBeenCalled();
30
28
 
31
- wrapper.vm.onObserve([] as IntersectionObserverEntry[], null as any as IntersectionObserver, false)
29
+ wrapper.vm.onObserve(
30
+ [] as IntersectionObserverEntry[],
31
+ (null as any) as IntersectionObserver,
32
+ false
33
+ );
32
34
 
33
- expect(callback).not.toHaveBeenCalled()
35
+ expect(callback).not.toHaveBeenCalled();
34
36
 
35
- wrapper.vm.onObserve([] as IntersectionObserverEntry[], null as any as IntersectionObserver, true)
37
+ wrapper.vm.onObserve(
38
+ [] as IntersectionObserverEntry[],
39
+ (null as any) as IntersectionObserver,
40
+ true
41
+ );
36
42
 
37
- expect(callback).toHaveBeenCalledTimes(1)
38
- })
39
- })
43
+ expect(callback).toHaveBeenCalledTimes(1);
44
+ });
45
+ });