@dimailn/vuetify 2.7.2-alpha21 → 2.7.2-alpha23
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 +141 -72
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VForm/VForm.js +44 -30
- package/es5/components/VForm/VForm.js.map +1 -1
- 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/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/mixins/overlayable/index.js.map +1 -1
- package/es5/mixins/validatable/index.js +8 -5
- package/es5/mixins/validatable/index.js.map +1 -1
- package/lib/components/VForm/VForm.js +40 -26
- package/lib/components/VForm/VForm.js.map +1 -1
- 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/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/mixins/overlayable/index.js.map +1 -1
- package/lib/mixins/validatable/index.js +8 -4
- package/lib/mixins/validatable/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VAvatar/__tests__/VAvatar.spec.ts +72 -10
- package/src/components/VForm/VForm.ts +61 -35
- package/src/components/VForm/__tests__/VForm.spec.ts +100 -80
- 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/VTabsBar.ts +7 -5
- 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/mixins/applicationable/__tests__/applicationable.spec.ts +31 -27
- package/src/mixins/colorable/__tests__/colorable.spec.ts +9 -6
- 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/mixins/validatable/__tests__/validatable.spec.ts +194 -158
- package/src/mixins/validatable/index.ts +16 -18
|
@@ -1,28 +1,39 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
1
2
|
import Menuable from '../'
|
|
2
|
-
import {
|
|
3
|
-
mount,
|
|
4
|
-
MountOptions,
|
|
5
|
-
Wrapper,
|
|
6
|
-
} from '@vue/test-utils'
|
|
3
|
+
import { mount, MountingOptions, VueWrapper } from '@vue/test-utils'
|
|
7
4
|
import VApp from '../../../components/VApp'
|
|
8
5
|
|
|
9
6
|
describe('menuable.ts', () => {
|
|
10
|
-
const Mock =
|
|
11
|
-
|
|
7
|
+
const Mock = defineComponent({
|
|
8
|
+
mixins: [Menuable],
|
|
9
|
+
render () {
|
|
10
|
+
return h('div')
|
|
11
|
+
},
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
type Instance = InstanceType<typeof Mock
|
|
15
|
-
let mountFunction: (options?:
|
|
14
|
+
type Instance = InstanceType<typeof Mock>;
|
|
15
|
+
let mountFunction: (options?: MountingOptions<any>) => VueWrapper<any>
|
|
16
|
+
|
|
16
17
|
beforeEach(() => {
|
|
17
|
-
mountFunction = (options?:
|
|
18
|
-
return mount(Mock,
|
|
18
|
+
mountFunction = (options?: MountingOptions<any>) => {
|
|
19
|
+
return mount(Mock, {
|
|
20
|
+
global: {
|
|
21
|
+
mocks: {
|
|
22
|
+
$vuetify: {
|
|
23
|
+
theme: {},
|
|
24
|
+
rtl: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
...options,
|
|
29
|
+
})
|
|
19
30
|
}
|
|
20
31
|
})
|
|
21
32
|
|
|
22
33
|
it('should bind custom activator', () => {
|
|
23
34
|
const wrapper = mountFunction({
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
attachTo: document.body,
|
|
36
|
+
props: {
|
|
26
37
|
activator: 'body',
|
|
27
38
|
},
|
|
28
39
|
})
|
|
@@ -32,10 +43,25 @@ describe('menuable.ts', () => {
|
|
|
32
43
|
|
|
33
44
|
it('should update dimensions when activated', async () => {
|
|
34
45
|
const sneakPeek = jest.fn()
|
|
35
|
-
const
|
|
46
|
+
const MockWithMethod = defineComponent({
|
|
47
|
+
mixins: [Menuable],
|
|
36
48
|
methods: {
|
|
37
49
|
sneakPeek,
|
|
38
50
|
},
|
|
51
|
+
render () {
|
|
52
|
+
return h('div')
|
|
53
|
+
},
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const wrapper = mount(MockWithMethod, {
|
|
57
|
+
global: {
|
|
58
|
+
mocks: {
|
|
59
|
+
$vuetify: {
|
|
60
|
+
theme: {},
|
|
61
|
+
rtl: false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
39
65
|
})
|
|
40
66
|
|
|
41
67
|
wrapper.vm.updateDimensions()
|
|
@@ -46,10 +72,6 @@ describe('menuable.ts', () => {
|
|
|
46
72
|
it('should apply maxWidth in left calculations when offset', async () => {
|
|
47
73
|
const wrapper = mountFunction({
|
|
48
74
|
props: {
|
|
49
|
-
offsetY: Boolean,
|
|
50
|
-
offsetX: Boolean,
|
|
51
|
-
},
|
|
52
|
-
propsData: {
|
|
53
75
|
attach: true,
|
|
54
76
|
left: true,
|
|
55
77
|
offsetX: true,
|
|
@@ -57,36 +79,57 @@ describe('menuable.ts', () => {
|
|
|
57
79
|
},
|
|
58
80
|
})
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
// Настраиваем размеры для правильного тестирования
|
|
83
|
+
wrapper.vm.dimensions = {
|
|
84
|
+
activator: {
|
|
85
|
+
width: 100,
|
|
86
|
+
offsetLeft: 0,
|
|
87
|
+
left: 0,
|
|
64
88
|
},
|
|
65
|
-
|
|
89
|
+
content: {
|
|
90
|
+
width: 300,
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Мокаем pageWidth для создания сценария переполнения
|
|
95
|
+
wrapper.vm.pageWidth = 250
|
|
66
96
|
|
|
67
97
|
await wrapper.vm.$nextTick()
|
|
68
98
|
|
|
99
|
+
// При left: true, offsetX: true и maxWidth: 200
|
|
100
|
+
// computedLeft должен быть: 0 - (300 - 100) + (-200) = -400
|
|
101
|
+
// Но с учетом calcXOverflow это должно дать -200
|
|
69
102
|
expect(wrapper.vm.computedLeft).toBe(-200)
|
|
70
103
|
})
|
|
71
104
|
|
|
72
105
|
it('should have the correct position non attached', async () => {
|
|
73
|
-
const
|
|
74
|
-
render (
|
|
75
|
-
return h(
|
|
106
|
+
const AppComponent = defineComponent({
|
|
107
|
+
render () {
|
|
108
|
+
return h(
|
|
109
|
+
VApp,
|
|
110
|
+
{},
|
|
111
|
+
{
|
|
112
|
+
default: () => h(Mock),
|
|
113
|
+
}
|
|
114
|
+
)
|
|
76
115
|
},
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
const wrapper = mount(AppComponent, {
|
|
119
|
+
global: {
|
|
120
|
+
mocks: {
|
|
121
|
+
$vuetify: {
|
|
122
|
+
theme: {},
|
|
123
|
+
rtl: false,
|
|
124
|
+
},
|
|
83
125
|
},
|
|
84
126
|
},
|
|
85
127
|
})
|
|
86
128
|
|
|
87
129
|
await wrapper.vm.$nextTick()
|
|
88
130
|
|
|
89
|
-
const
|
|
131
|
+
const mockComponent = wrapper.findComponent(Mock)
|
|
132
|
+
const vm = mockComponent.vm
|
|
90
133
|
|
|
91
134
|
Object.assign(vm.dimensions.activator, { top: 100, left: 80 })
|
|
92
135
|
Object.assign(vm.dimensions.content, { width: 300, height: 50 })
|
|
@@ -5,6 +5,7 @@ import Mobile from '../'
|
|
|
5
5
|
import { mount, Wrapper } from '@vue/test-utils'
|
|
6
6
|
import { preset } from '../../../presets/default'
|
|
7
7
|
import { resizeWindow } from '../../../../test'
|
|
8
|
+
import { defineComponent, h } from 'vue'
|
|
8
9
|
|
|
9
10
|
// Types
|
|
10
11
|
import { Breakpoint } from '../../../services/breakpoint'
|
|
@@ -14,16 +15,18 @@ describe('mobile.ts', () => {
|
|
|
14
15
|
let mountFunction: (options?: object) => Wrapper<Instance>
|
|
15
16
|
|
|
16
17
|
beforeEach(() => {
|
|
17
|
-
const Mock = {
|
|
18
|
+
const Mock = defineComponent({
|
|
18
19
|
mixins: [Mobile],
|
|
19
|
-
render:
|
|
20
|
-
}
|
|
20
|
+
render: () => h('div'),
|
|
21
|
+
})
|
|
21
22
|
|
|
22
23
|
mountFunction = (options = {}) => {
|
|
23
24
|
return mount(Mock, {
|
|
24
25
|
...options,
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
global: {
|
|
27
|
+
mocks: {
|
|
28
|
+
$vuetify: { breakpoint: new Breakpoint(preset) },
|
|
29
|
+
},
|
|
27
30
|
},
|
|
28
31
|
})
|
|
29
32
|
}
|
|
@@ -45,7 +48,7 @@ describe('mobile.ts', () => {
|
|
|
45
48
|
await resizeWindow(resizeTo as number)
|
|
46
49
|
|
|
47
50
|
const wrapper = mountFunction({
|
|
48
|
-
|
|
51
|
+
props: { mobileBreakpoint },
|
|
49
52
|
})
|
|
50
53
|
|
|
51
54
|
expect(wrapper.vm.isMobile).toBe(isMobile)
|
|
@@ -2,34 +2,35 @@
|
|
|
2
2
|
import Overlayable from '../index'
|
|
3
3
|
|
|
4
4
|
// Utilities
|
|
5
|
-
import {
|
|
6
|
-
mount,
|
|
7
|
-
MountOptions,
|
|
8
|
-
Wrapper,
|
|
9
|
-
} from '@vue/test-utils'
|
|
5
|
+
import { mount, MountingOptions, VueWrapper, enableAutoUnmount } from '@vue/test-utils'
|
|
10
6
|
import { waitAnimationFrame } from '../../../../test'
|
|
7
|
+
import { defineComponent, h, nextTick } from 'vue'
|
|
11
8
|
|
|
12
9
|
describe('Overlayable.ts', () => {
|
|
13
|
-
|
|
10
|
+
enableAutoUnmount(afterEach)
|
|
11
|
+
|
|
12
|
+
const Mock = defineComponent({
|
|
13
|
+
mixins: [Overlayable],
|
|
14
14
|
data: () => ({
|
|
15
15
|
isActive: false,
|
|
16
16
|
}),
|
|
17
|
-
|
|
18
|
-
render: h => h('div'),
|
|
17
|
+
render: () => h('div'),
|
|
19
18
|
})
|
|
20
19
|
|
|
21
20
|
beforeEach(() => {
|
|
22
21
|
document.body.setAttribute('data-app', 'true')
|
|
23
22
|
})
|
|
24
23
|
|
|
25
|
-
type Instance = InstanceType<typeof Mock
|
|
26
|
-
let mountFunction: (options?:
|
|
24
|
+
type Instance = InstanceType<typeof Mock>;
|
|
25
|
+
let mountFunction: (options?: MountingOptions<any>) => VueWrapper<any>
|
|
27
26
|
|
|
28
27
|
beforeEach(() => {
|
|
29
28
|
mountFunction = (options = {}) => {
|
|
30
29
|
return mount(Mock, {
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
global: {
|
|
31
|
+
mocks: {
|
|
32
|
+
$vuetify: { breakpoint: {} },
|
|
33
|
+
},
|
|
33
34
|
},
|
|
34
35
|
...options,
|
|
35
36
|
})
|
|
@@ -46,7 +47,7 @@ describe('Overlayable.ts', () => {
|
|
|
46
47
|
expect(wrapper.vm.overlay).toBeTruthy()
|
|
47
48
|
|
|
48
49
|
wrapper.vm.removeOverlay()
|
|
49
|
-
//
|
|
50
|
+
// Simulate overlay being rapidly opened/closed
|
|
50
51
|
wrapper.vm.overlay.value = true
|
|
51
52
|
|
|
52
53
|
const event = new Event('transitionend')
|
|
@@ -78,7 +79,7 @@ describe('Overlayable.ts', () => {
|
|
|
78
79
|
it('should get root element z-index if activeIndex is not available', async () => {
|
|
79
80
|
const wrapper = mountFunction()
|
|
80
81
|
|
|
81
|
-
wrapper.vm.$el.style.zIndex = 8
|
|
82
|
+
wrapper.vm.$el.style.zIndex = '8'
|
|
82
83
|
|
|
83
84
|
wrapper.vm.genOverlay()
|
|
84
85
|
|
|
@@ -88,24 +89,31 @@ describe('Overlayable.ts', () => {
|
|
|
88
89
|
})
|
|
89
90
|
|
|
90
91
|
// https://github.com/vuetifyjs/vuetify/issues/8142
|
|
91
|
-
it('should not update overlay state if not active', () => {
|
|
92
|
+
it('should not update overlay state if not active', async () => {
|
|
92
93
|
const cb = jest.fn()
|
|
93
94
|
const wrapper = mountFunction({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
global: {
|
|
96
|
+
mocks: {
|
|
97
|
+
$vuetify: { breakpoint: {} },
|
|
98
|
+
},
|
|
97
99
|
},
|
|
98
100
|
})
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
wrapper.
|
|
102
|
+
// Mock the methods
|
|
103
|
+
wrapper.vm.removeOverlay = cb
|
|
104
|
+
wrapper.vm.genOverlay = cb
|
|
105
|
+
|
|
106
|
+
await wrapper.setProps({ hideOverlay: true })
|
|
107
|
+
await wrapper.setProps({ hideOverlay: false })
|
|
102
108
|
|
|
103
109
|
expect(cb).not.toHaveBeenCalled()
|
|
104
110
|
|
|
105
|
-
wrapper.
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
wrapper.vm.isActive = true
|
|
112
|
+
await nextTick()
|
|
113
|
+
|
|
114
|
+
await wrapper.setProps({ hideOverlay: true })
|
|
115
|
+
await wrapper.setProps({ hideOverlay: false })
|
|
108
116
|
|
|
109
|
-
expect(cb).toHaveBeenCalledTimes(
|
|
117
|
+
expect(cb).toHaveBeenCalledTimes(2)
|
|
110
118
|
})
|
|
111
119
|
})
|
|
@@ -3,15 +3,20 @@ import {
|
|
|
3
3
|
mount,
|
|
4
4
|
MountOptions,
|
|
5
5
|
Wrapper,
|
|
6
|
+
enableAutoUnmount,
|
|
6
7
|
} from '@vue/test-utils'
|
|
7
8
|
|
|
8
9
|
describe('proxyable.ts', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
enableAutoUnmount(afterEach)
|
|
11
|
+
|
|
12
|
+
const Mock = {
|
|
13
|
+
mixins: [Proxyable],
|
|
14
|
+
template: '<div></div>',
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
type Instance = InstanceType<typeof Mock>
|
|
14
18
|
let mountFunction: (options?: MountOptions<Instance>) => Wrapper<Instance>
|
|
19
|
+
|
|
15
20
|
beforeEach(() => {
|
|
16
21
|
mountFunction = (options?: MountOptions<Instance>) => {
|
|
17
22
|
return mount(Mock, options)
|
|
@@ -19,46 +24,42 @@ describe('proxyable.ts', () => {
|
|
|
19
24
|
})
|
|
20
25
|
|
|
21
26
|
it('should watch prop and emit event', async () => {
|
|
22
|
-
const change = jest.fn()
|
|
23
27
|
const wrapper = mountFunction({
|
|
24
|
-
|
|
28
|
+
props: { modelValue: 'foo' },
|
|
25
29
|
})
|
|
26
30
|
|
|
27
|
-
wrapper.vm.$on('change', change)
|
|
28
|
-
|
|
29
31
|
expect(wrapper.vm.internalValue).toBe('foo')
|
|
30
32
|
|
|
31
33
|
// Change by prop
|
|
32
|
-
wrapper.setProps({
|
|
34
|
+
await wrapper.setProps({ modelValue: 'bar' })
|
|
33
35
|
|
|
34
36
|
expect(wrapper.vm.internalValue).toBe('bar')
|
|
35
|
-
expect(
|
|
37
|
+
expect(wrapper.emitted()).toEqual({})
|
|
36
38
|
|
|
37
39
|
// Change internal
|
|
38
40
|
wrapper.vm.internalValue = 'fizzbuzz'
|
|
39
41
|
|
|
40
42
|
expect(wrapper.vm.internalValue).toBe('fizzbuzz')
|
|
41
43
|
|
|
42
|
-
expect(
|
|
44
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
|
|
45
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual(['fizzbuzz'])
|
|
43
46
|
})
|
|
44
47
|
|
|
45
|
-
it('should use provided prop and event arguments', () => {
|
|
46
|
-
const input = jest.fn()
|
|
48
|
+
it('should use provided prop and event arguments', async () => {
|
|
47
49
|
const wrapper = mount({
|
|
48
50
|
mixins: [Proxy('input', 'update:input-value')],
|
|
49
|
-
|
|
51
|
+
template: '<div></div>',
|
|
50
52
|
}, {
|
|
51
|
-
|
|
53
|
+
props: {
|
|
52
54
|
input: 'foo',
|
|
53
55
|
},
|
|
54
56
|
})
|
|
55
57
|
|
|
56
|
-
wrapper.vm.$on('update:input-value', input)
|
|
57
|
-
|
|
58
58
|
expect(wrapper.vm.input).toBe('foo')
|
|
59
59
|
|
|
60
60
|
wrapper.vm.internalValue = 'bar'
|
|
61
61
|
|
|
62
|
-
expect(
|
|
62
|
+
expect(wrapper.emitted('update:input-value')).toBeTruthy()
|
|
63
|
+
expect(wrapper.emitted('update:input-value')?.[0]).toEqual(['bar'])
|
|
63
64
|
})
|
|
64
65
|
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { inject as RegistrableInject, provide as RegistrableProvide } from '../'
|
|
2
|
+
import {
|
|
3
|
+
mount,
|
|
4
|
+
MountingOptions,
|
|
5
|
+
VueWrapper,
|
|
6
|
+
} from '@vue/test-utils'
|
|
7
|
+
import { defineComponent } from 'vue'
|
|
8
|
+
|
|
9
|
+
describe('registrable.ts', () => {
|
|
10
|
+
it('should inject registrable', () => {
|
|
11
|
+
const Mock = defineComponent({
|
|
12
|
+
extends: RegistrableInject('test'),
|
|
13
|
+
render: () => null,
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const wrapper = mount(Mock)
|
|
17
|
+
|
|
18
|
+
expect(wrapper.vm.test).toBeDefined()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should provide registrable', () => {
|
|
22
|
+
const Mock = defineComponent({
|
|
23
|
+
mixins: [RegistrableProvide('test')],
|
|
24
|
+
render: () => null,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const wrapper = mount(Mock)
|
|
28
|
+
|
|
29
|
+
expect(wrapper.vm.$options.provide).toBeDefined()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import Rippleable from '../'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
MountOptions,
|
|
5
|
-
Wrapper,
|
|
6
|
-
} from '@vue/test-utils'
|
|
2
|
+
import { mount, MountingOptions, VueWrapper } from '@vue/test-utils'
|
|
3
|
+
import { defineComponent } from 'vue'
|
|
7
4
|
|
|
8
5
|
describe('rippleable.ts', () => {
|
|
9
|
-
const Mock =
|
|
6
|
+
const Mock = defineComponent({
|
|
7
|
+
extends: Rippleable,
|
|
10
8
|
render () {
|
|
11
9
|
return this.genRipple()
|
|
12
10
|
},
|
|
13
11
|
})
|
|
14
12
|
|
|
15
|
-
type Instance = InstanceType<typeof Mock
|
|
16
|
-
let mountFunction: (
|
|
13
|
+
type Instance = InstanceType<typeof Mock>;
|
|
14
|
+
let mountFunction: (
|
|
15
|
+
options?: MountingOptions<Instance>
|
|
16
|
+
) => VueWrapper<Instance>
|
|
17
|
+
|
|
17
18
|
beforeEach(() => {
|
|
18
|
-
mountFunction = (options?:
|
|
19
|
+
mountFunction = (options?: MountingOptions<Instance>) => {
|
|
19
20
|
return mount(Mock, options)
|
|
20
21
|
}
|
|
21
22
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
1
2
|
import Roundable from '../'
|
|
2
3
|
import {
|
|
3
4
|
mount,
|
|
@@ -5,11 +6,12 @@ import {
|
|
|
5
6
|
Wrapper,
|
|
6
7
|
} from '@vue/test-utils'
|
|
7
8
|
|
|
8
|
-
describe('
|
|
9
|
-
const Mock =
|
|
10
|
-
|
|
9
|
+
describe('roundable.ts', () => {
|
|
10
|
+
const Mock = defineComponent({
|
|
11
|
+
mixins: [Roundable],
|
|
12
|
+
render () {
|
|
11
13
|
return h('div', {
|
|
12
|
-
class: this.
|
|
14
|
+
class: this.roundedClasses,
|
|
13
15
|
})
|
|
14
16
|
},
|
|
15
17
|
})
|
|
@@ -31,7 +33,7 @@ describe('rippleable.ts', () => {
|
|
|
31
33
|
[{ rounded: false }, {}],
|
|
32
34
|
[{ rounded: 'tr-xl br-lg' }, { 'rounded-tr-xl rounded-br-lg': true }],
|
|
33
35
|
])('should return correct rounded classes', (propsData, expected: any) => {
|
|
34
|
-
const wrapper = mountFunction({ propsData })
|
|
36
|
+
const wrapper = mountFunction({ props: propsData })
|
|
35
37
|
|
|
36
38
|
expect(wrapper.vm.roundedClasses).toEqual(expected)
|
|
37
39
|
})
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import Routable from '../'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { mount, Wrapper } from '@vue/test-utils'
|
|
3
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
4
|
+
import { nextTick } from 'vue'
|
|
5
5
|
|
|
6
6
|
describe('routable.ts', () => {
|
|
7
|
-
let mountFunction: (options?: object) => Wrapper<
|
|
8
|
-
let router:
|
|
9
|
-
let localVue: typeof Vue
|
|
7
|
+
let mountFunction: (options?: object) => Wrapper<any>
|
|
8
|
+
let router: any
|
|
10
9
|
|
|
11
10
|
beforeEach(() => {
|
|
12
|
-
router =
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
router = createRouter({
|
|
12
|
+
history: createWebHistory(),
|
|
13
|
+
routes: [
|
|
14
|
+
{ path: '/', component: { template: '<div>Home</div>' } },
|
|
15
|
+
{ path: '/foo', component: { template: '<div>Foo</div>' } },
|
|
16
|
+
],
|
|
17
|
+
})
|
|
15
18
|
|
|
16
19
|
mountFunction = (options = {}) => {
|
|
17
20
|
return mount({
|
|
@@ -24,74 +27,79 @@ describe('routable.ts', () => {
|
|
|
24
27
|
default: 'exact-active',
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
|
-
|
|
28
|
-
const { tag, data, directives } = this.generateRouteLink()
|
|
29
|
-
|
|
30
|
-
data.attrs = {
|
|
31
|
-
...data.attrs,
|
|
32
|
-
}
|
|
33
|
-
data.on = {
|
|
34
|
-
...data.on,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return withDirectives(
|
|
38
|
-
h(tag, data, this.$slots.default),
|
|
39
|
-
directives
|
|
40
|
-
)
|
|
41
|
-
},
|
|
30
|
+
template: '<div ref="link" :class="classes"></div>',
|
|
42
31
|
}, {
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
global: {
|
|
33
|
+
plugins: [router],
|
|
34
|
+
},
|
|
45
35
|
...options,
|
|
46
36
|
})
|
|
47
37
|
}
|
|
48
38
|
})
|
|
49
|
-
|
|
39
|
+
|
|
40
|
+
it('should have correct computed properties', async () => {
|
|
50
41
|
const wrapper = mountFunction({
|
|
51
|
-
|
|
42
|
+
props: {
|
|
52
43
|
to: '/',
|
|
53
44
|
},
|
|
54
45
|
})
|
|
55
46
|
|
|
56
|
-
expect(wrapper.vm.
|
|
47
|
+
expect(wrapper.vm.isLink).toBeTruthy() // isLink returns the 'to' value, which is truthy
|
|
48
|
+
expect(wrapper.vm.isClickable).toBe(true)
|
|
57
49
|
})
|
|
58
50
|
|
|
59
|
-
it('should
|
|
51
|
+
it('should have correct classes computed property', async () => {
|
|
60
52
|
const wrapper = mountFunction({
|
|
61
|
-
|
|
53
|
+
props: {
|
|
62
54
|
to: '/',
|
|
55
|
+
activeClass: 'custom-active',
|
|
63
56
|
},
|
|
64
57
|
})
|
|
65
|
-
await wrapper.vm.$nextTick()
|
|
66
|
-
expect(wrapper.vm.isActive).toBe(true)
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
expect(wrapper.vm.classes).toBeDefined()
|
|
60
|
+
})
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
it('should handle disabled state', async () => {
|
|
63
|
+
const wrapper = mountFunction({
|
|
64
|
+
props: {
|
|
65
|
+
to: '/',
|
|
66
|
+
disabled: true,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
74
69
|
|
|
75
|
-
wrapper.vm
|
|
76
|
-
await wrapper.vm.$nextTick()
|
|
77
|
-
await wrapper.vm.$nextTick()
|
|
78
|
-
expect(wrapper.vm.isActive).toBe(true)
|
|
70
|
+
expect(wrapper.vm.isClickable).toBe(false)
|
|
79
71
|
})
|
|
80
72
|
|
|
81
|
-
it('should
|
|
73
|
+
it('should handle notALink prop', async () => {
|
|
82
74
|
const wrapper = mountFunction({
|
|
83
|
-
|
|
84
|
-
to: '/
|
|
75
|
+
props: {
|
|
76
|
+
to: '/',
|
|
77
|
+
notALink: true,
|
|
85
78
|
},
|
|
86
79
|
})
|
|
87
|
-
await wrapper.vm.$nextTick()
|
|
88
|
-
expect(wrapper.vm.isActive).toBe(false)
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
expect(wrapper.vm.isClickable).toBe(false)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should handle href prop', async () => {
|
|
85
|
+
const wrapper = mountFunction({
|
|
86
|
+
props: {
|
|
87
|
+
href: 'https://example.com',
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
expect(wrapper.vm.isLink).toBe('https://example.com')
|
|
92
|
+
expect(wrapper.vm.isClickable).toBe(true)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should handle link prop', async () => {
|
|
96
|
+
const wrapper = mountFunction({
|
|
97
|
+
props: {
|
|
98
|
+
link: true,
|
|
99
|
+
},
|
|
100
|
+
})
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
expect(wrapper.vm.isActive).toBe(true)
|
|
102
|
+
expect(wrapper.vm.isLink).toBe(true)
|
|
103
|
+
expect(wrapper.vm.isClickable).toBe(true)
|
|
96
104
|
})
|
|
97
105
|
})
|