@dimailn/vuetify 2.7.2-alpha29 → 2.7.2-alpha31
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 +166 -78
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js +8 -6
- package/es5/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/es5/components/VBreadcrumbs/VBreadcrumbsItem.js +4 -0
- package/es5/components/VBreadcrumbs/VBreadcrumbsItem.js.map +1 -1
- package/es5/components/VCarousel/VCarousel.js +14 -2
- package/es5/components/VCarousel/VCarousel.js.map +1 -1
- package/es5/components/VDialog/VDialog.js +47 -26
- package/es5/components/VDialog/VDialog.js.map +1 -1
- package/es5/components/VFileInput/VFileInput.js +50 -28
- package/es5/components/VFileInput/VFileInput.js.map +1 -1
- package/es5/components/VPagination/VPagination.js +15 -18
- package/es5/components/VPagination/VPagination.js.map +1 -1
- package/es5/components/VRangeSlider/VRangeSlider.js +57 -32
- package/es5/components/VRangeSlider/VRangeSlider.js.map +1 -1
- package/es5/components/VSubheader/VSubheader.js +1 -1
- package/es5/components/VSubheader/VSubheader.js.map +1 -1
- package/es5/components/VTreeview/VTreeview.js +26 -13
- package/es5/components/VTreeview/VTreeview.js.map +1 -1
- package/es5/components/VTreeview/VTreeviewNode.js +0 -2
- package/es5/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/es5/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/es5/framework.js +1 -1
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js +7 -5
- package/lib/components/VBreadcrumbs/VBreadcrumbs.js.map +1 -1
- package/lib/components/VBreadcrumbs/VBreadcrumbsItem.js +4 -0
- package/lib/components/VBreadcrumbs/VBreadcrumbsItem.js.map +1 -1
- package/lib/components/VCarousel/VCarousel.js +14 -2
- package/lib/components/VCarousel/VCarousel.js.map +1 -1
- package/lib/components/VDialog/VDialog.js +9 -2
- package/lib/components/VDialog/VDialog.js.map +1 -1
- package/lib/components/VFileInput/VFileInput.js +43 -26
- package/lib/components/VFileInput/VFileInput.js.map +1 -1
- package/lib/components/VPagination/VPagination.js +15 -19
- package/lib/components/VPagination/VPagination.js.map +1 -1
- package/lib/components/VRangeSlider/VRangeSlider.js +16 -4
- package/lib/components/VRangeSlider/VRangeSlider.js.map +1 -1
- package/lib/components/VSubheader/VSubheader.js +1 -1
- package/lib/components/VSubheader/VSubheader.js.map +1 -1
- package/lib/components/VTreeview/VTreeview.js +15 -7
- package/lib/components/VTreeview/VTreeview.js.map +1 -1
- package/lib/components/VTreeview/VTreeviewNode.js +0 -2
- package/lib/components/VTreeview/VTreeviewNode.js.map +1 -1
- package/lib/components/VVirtualScroll/VVirtualScroll.js.map +1 -1
- package/lib/framework.js +1 -1
- package/package.json +1 -1
- package/src/components/VBottomNavigation/__tests__/VBottomNavigation.spec.ts +43 -37
- package/src/components/VBottomNavigation/__tests__/__snapshots__/VBottomNavigation.spec.ts.snap +11 -10
- package/src/components/VBreadcrumbs/VBreadcrumbs.ts +8 -4
- package/src/components/VBreadcrumbs/VBreadcrumbsItem.ts +4 -0
- package/src/components/VBreadcrumbs/__tests__/VBreadcrumbs.spec.ts +125 -10
- package/src/components/VBreadcrumbs/__tests__/VBreadcrumbsItem.spec.ts +10 -6
- package/src/components/VBtnToggle/__tests__/VBtnToggle.spec.ts +10 -6
- package/src/components/VCarousel/VCarousel.ts +15 -3
- package/src/components/VCarousel/__tests__/VCarousel.spec.ts +74 -54
- package/src/components/VCarousel/__tests__/VCarouselItem.spec.ts +9 -5
- package/src/components/VCarousel/__tests__/__snapshots__/VCarousel.spec.ts.snap +1 -1
- package/src/components/VDialog/VDialog.ts +14 -4
- package/src/components/VDialog/__tests__/VDialog.spec.ts +105 -101
- package/src/components/VDialog/__tests__/__snapshots__/VDialog.spec.ts.snap +0 -15
- package/src/components/VExpansionPanel/__tests__/VExpansionPanel.spec.ts +43 -27
- package/src/components/VExpansionPanel/__tests__/__snapshots__/VExpansionPanel.spec.ts.snap +18 -16
- package/src/components/VFileInput/VFileInput.ts +46 -33
- package/src/components/VFileInput/__tests__/VFileInput.spec.ts +84 -54
- package/src/components/VFileInput/__tests__/__snapshots__/VFileInput.spec.ts.snap +242 -146
- package/src/components/VImg/__tests__/VImg.spec.ts +21 -20
- package/src/components/VImg/__tests__/__snapshots__/VImg.spec.ts.snap +16 -11
- package/src/components/VNavigationDrawer/__tests__/VNavigationDrawer.spec.ts +84 -71
- package/src/components/VPagination/VPagination.ts +16 -19
- package/src/components/VPagination/__tests__/VPagination.spec.ts +85 -71
- package/src/components/VPagination/__tests__/__snapshots__/VPagination.spec.ts.snap +184 -429
- package/src/components/VRangeSlider/VRangeSlider.ts +19 -4
- package/src/components/VRangeSlider/__tests__/VRangeSlider.spec.ts +40 -40
- package/src/components/VRangeSlider/__tests__/__snapshots__/VRangeSlider.spec.ts.snap +32 -38
- package/src/components/VSubheader/VSubheader.ts +1 -1
- package/src/components/VSubheader/__tests__/VSubheader.spec.ts +12 -7
- package/src/components/VSubheader/__tests__/__snapshots__/VSubheader.spec.ts.snap +1 -1
- package/src/components/VSystemBar/__tests__/VSystemBar.spec.ts +89 -17
- package/src/components/VTimeline/__tests__/VTimelineItem.spec.ts +25 -35
- package/src/components/VTimeline/__tests__/__snapshots__/VTimelineItem.spec.ts.snap +4 -5
- package/src/components/VTreeview/VTreeview.ts +20 -12
- package/src/components/VTreeview/VTreeviewNode.ts +0 -2
- package/src/components/VTreeview/__tests__/VTreeview.spec.ts +168 -174
- package/src/components/VTreeview/__tests__/VTreeviewNode.spec.ts +77 -66
- package/src/components/VTreeview/__tests__/__snapshots__/VTreeview.spec.ts.snap +141 -141
- package/src/components/VTreeview/__tests__/__snapshots__/VTreeviewNode.spec.ts.snap +26 -51
- package/src/components/VVirtualScroll/VVirtualScroll.ts +0 -1
- package/src/components/VVirtualScroll/__tests__/VVirtualScroll.spec.ts +6 -9
- package/src/components/VWindow/__tests__/VWindow.spec.ts +78 -0
- package/src/components/VWindow/__tests__/VWindowItem.spec.ts +127 -0
- package/src/components/VWindow/__tests__/__snapshots__/VWindow.spec.ts.snap +59 -0
- package/src/components/VWindow/__tests__/__snapshots__/VWindowItem.spec.ts.snap +36 -0
|
@@ -81,9 +81,6 @@ export default mixins(
|
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
computed: {
|
|
84
|
-
value () {
|
|
85
|
-
return this.modelValue
|
|
86
|
-
},
|
|
87
84
|
classes (): object {
|
|
88
85
|
return {
|
|
89
86
|
'v-pagination': true,
|
|
@@ -114,20 +111,20 @@ export default mixins(
|
|
|
114
111
|
const left = Math.floor(maxLength / 2)
|
|
115
112
|
const right = this.length - left + 1 + even
|
|
116
113
|
|
|
117
|
-
if (this.
|
|
114
|
+
if (this.modelValue > left && this.modelValue < right) {
|
|
118
115
|
const firstItem = 1
|
|
119
116
|
const lastItem = this.length
|
|
120
|
-
const start = this.
|
|
121
|
-
const end = this.
|
|
117
|
+
const start = this.modelValue - left + 2
|
|
118
|
+
const end = this.modelValue + left - 2 - even
|
|
122
119
|
const secondItem = start - 1 === firstItem + 1 ? 2 : '...'
|
|
123
120
|
const beforeLastItem = end + 1 === lastItem - 1 ? end + 1 : '...'
|
|
124
121
|
|
|
125
122
|
return [1, secondItem, ...this.range(start, end), beforeLastItem, this.length]
|
|
126
|
-
} else if (this.
|
|
127
|
-
const end = this.
|
|
123
|
+
} else if (this.modelValue === left) {
|
|
124
|
+
const end = this.modelValue + left - 1 - even
|
|
128
125
|
return [...this.range(1, end), '...', this.length]
|
|
129
|
-
} else if (this.
|
|
130
|
-
const start = this.
|
|
126
|
+
} else if (this.modelValue === right) {
|
|
127
|
+
const start = this.modelValue - left + 1
|
|
131
128
|
return [1, '...', ...this.range(start, this.length)]
|
|
132
129
|
} else {
|
|
133
130
|
return [
|
|
@@ -152,7 +149,7 @@ export default mixins(
|
|
|
152
149
|
},
|
|
153
150
|
|
|
154
151
|
watch: {
|
|
155
|
-
|
|
152
|
+
modelValue () {
|
|
156
153
|
this.init()
|
|
157
154
|
},
|
|
158
155
|
},
|
|
@@ -168,7 +165,7 @@ export default mixins(
|
|
|
168
165
|
this.onResize()
|
|
169
166
|
this.$nextTick(this.onResize)
|
|
170
167
|
// TODO: Change this (f75dee3a, cbdf7caa)
|
|
171
|
-
setTimeout(() => (this.selected = this.
|
|
168
|
+
setTimeout(() => (this.selected = this.modelValue), 100)
|
|
172
169
|
},
|
|
173
170
|
onResize () {
|
|
174
171
|
const width = this.$el && this.$el.parentElement
|
|
@@ -179,12 +176,12 @@ export default mixins(
|
|
|
179
176
|
},
|
|
180
177
|
next (e: Event) {
|
|
181
178
|
e.preventDefault()
|
|
182
|
-
this.$emit('update:modelValue', this.
|
|
179
|
+
this.$emit('update:modelValue', this.modelValue + 1)
|
|
183
180
|
this.$emit('next')
|
|
184
181
|
},
|
|
185
182
|
previous (e: Event) {
|
|
186
183
|
e.preventDefault()
|
|
187
|
-
this.$emit('update:modelValue', this.
|
|
184
|
+
this.$emit('update:modelValue', this.modelValue - 1)
|
|
188
185
|
this.$emit('previous')
|
|
189
186
|
},
|
|
190
187
|
range (from: number, to: number) {
|
|
@@ -215,13 +212,13 @@ export default mixins(
|
|
|
215
212
|
])
|
|
216
213
|
},
|
|
217
214
|
genItem (h: CreateElement, i: string | number): VNode {
|
|
218
|
-
const color: string | false = (i === this.
|
|
219
|
-
const isCurrentPage = i === this.
|
|
215
|
+
const color: string | false = (i === this.modelValue) && (this.color || 'primary')
|
|
216
|
+
const isCurrentPage = i === this.modelValue
|
|
220
217
|
const ariaLabel = isCurrentPage ? this.currentPageAriaLabel : this.pageAriaLabel
|
|
221
218
|
|
|
222
219
|
return h('button', this.setBackgroundColor(color, {
|
|
223
220
|
class: ['v-pagination__item', {
|
|
224
|
-
'v-pagination__item--active': i === this.
|
|
221
|
+
'v-pagination__item--active': i === this.modelValue,
|
|
225
222
|
}],
|
|
226
223
|
type: 'button',
|
|
227
224
|
'aria-current': isCurrentPage,
|
|
@@ -254,14 +251,14 @@ export default mixins(
|
|
|
254
251
|
const children = [
|
|
255
252
|
this.genIcon(h,
|
|
256
253
|
this.$vuetify.rtl ? this.nextIcon : this.prevIcon,
|
|
257
|
-
this.
|
|
254
|
+
this.modelValue <= 1,
|
|
258
255
|
this.previous,
|
|
259
256
|
this.$vuetify.lang.t(this.previousAriaLabel),
|
|
260
257
|
),
|
|
261
258
|
this.genItems(h),
|
|
262
259
|
this.genIcon(h,
|
|
263
260
|
this.$vuetify.rtl ? this.prevIcon : this.nextIcon,
|
|
264
|
-
this.
|
|
261
|
+
this.modelValue >= this.length,
|
|
265
262
|
this.next,
|
|
266
263
|
this.$vuetify.lang.t(this.nextAriaLabel),
|
|
267
264
|
),
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
import VPagination from '../VPagination'
|
|
2
2
|
import {
|
|
3
3
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
VueWrapper,
|
|
5
|
+
MountingOptions,
|
|
6
|
+
enableAutoUnmount,
|
|
6
7
|
} from '@vue/test-utils'
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
rtl: false,
|
|
11
|
-
icons: {
|
|
12
|
-
values: {
|
|
13
|
-
next: 'mdi-chevron-right',
|
|
14
|
-
prev: 'mdi-chevron-left',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
lang: {
|
|
18
|
-
t: str => str,
|
|
19
|
-
},
|
|
20
|
-
}
|
|
8
|
+
import { h } from 'vue'
|
|
9
|
+
import { Lang } from '../../../services/lang'
|
|
10
|
+
import { preset } from '../../../presets/default'
|
|
21
11
|
|
|
22
12
|
describe('VPagination.ts', () => {
|
|
23
13
|
type Instance = InstanceType<typeof VPagination>
|
|
24
|
-
let mountFunction: (options?:
|
|
14
|
+
let mountFunction: (options?: MountingOptions<Instance>) => VueWrapper<Instance>
|
|
15
|
+
|
|
16
|
+
enableAutoUnmount(afterEach)
|
|
17
|
+
|
|
25
18
|
beforeEach(() => {
|
|
26
19
|
jest.useFakeTimers()
|
|
27
20
|
|
|
28
|
-
mountFunction = (options?:
|
|
21
|
+
mountFunction = (options?: MountingOptions<Instance>) => {
|
|
22
|
+
const vuetifyInstance = {
|
|
23
|
+
rtl: false,
|
|
24
|
+
icons: {
|
|
25
|
+
values: {
|
|
26
|
+
next: 'mdi-chevron-right',
|
|
27
|
+
prev: 'mdi-chevron-left',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
lang: new Lang(preset),
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
return mount(VPagination, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
global: {
|
|
35
|
+
config: {
|
|
36
|
+
globalProperties: {
|
|
37
|
+
$vuetify: vuetifyInstance,
|
|
34
38
|
},
|
|
35
39
|
},
|
|
40
|
+
mocks: {
|
|
41
|
+
$vuetify: vuetifyInstance,
|
|
42
|
+
},
|
|
36
43
|
},
|
|
37
44
|
...options,
|
|
38
45
|
})
|
|
@@ -41,35 +48,29 @@ describe('VPagination.ts', () => {
|
|
|
41
48
|
|
|
42
49
|
it('emits an event when next or previous is clicked', async () => {
|
|
43
50
|
const wrapper = mountFunction({
|
|
44
|
-
|
|
51
|
+
props: {
|
|
45
52
|
length: 5,
|
|
46
|
-
|
|
53
|
+
modelValue: 2,
|
|
47
54
|
},
|
|
48
55
|
})
|
|
49
56
|
jest.runAllTimers()
|
|
50
57
|
|
|
51
58
|
await wrapper.vm.$nextTick()
|
|
52
59
|
|
|
53
|
-
const
|
|
54
|
-
const next = jest.fn()
|
|
55
|
-
|
|
56
|
-
wrapper.vm.$on('previous', previous)
|
|
57
|
-
wrapper.vm.$on('next', next)
|
|
58
|
-
|
|
59
|
-
const navigation = wrapper.findAll('.v-pagination__navigation').wrappers
|
|
60
|
+
const navigation = wrapper.findAll('.v-pagination__navigation')
|
|
60
61
|
navigation[0].trigger('click')
|
|
61
62
|
navigation[1].trigger('click')
|
|
62
63
|
|
|
63
|
-
expect(
|
|
64
|
-
expect(
|
|
64
|
+
expect(wrapper.emitted('previous')).toBeTruthy()
|
|
65
|
+
expect(wrapper.emitted('next')).toBeTruthy()
|
|
65
66
|
expect(wrapper.html()).toMatchSnapshot()
|
|
66
67
|
})
|
|
67
68
|
|
|
68
69
|
it('should render component in RTL mode and match snapshot', async () => {
|
|
69
70
|
const wrapper = mountFunction({
|
|
70
|
-
|
|
71
|
+
props: {
|
|
71
72
|
length: 5,
|
|
72
|
-
|
|
73
|
+
modelValue: 2,
|
|
73
74
|
},
|
|
74
75
|
})
|
|
75
76
|
wrapper.vm.$vuetify.rtl = true
|
|
@@ -81,30 +82,27 @@ describe('VPagination.ts', () => {
|
|
|
81
82
|
|
|
82
83
|
it('emits an event when pagination item is clicked', async () => {
|
|
83
84
|
const wrapper = mountFunction({
|
|
84
|
-
|
|
85
|
+
props: {
|
|
85
86
|
length: 5,
|
|
86
|
-
|
|
87
|
+
modelValue: 2,
|
|
87
88
|
},
|
|
88
89
|
})
|
|
89
90
|
jest.runAllTimers()
|
|
90
91
|
|
|
91
92
|
await wrapper.vm.$nextTick()
|
|
92
93
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
wrapper.vm.$on('input', cb)
|
|
96
|
-
|
|
97
|
-
const navigation = wrapper.findAll('.v-pagination__item').wrappers
|
|
94
|
+
const navigation = wrapper.findAll('.v-pagination__item')
|
|
98
95
|
navigation[1].trigger('click')
|
|
99
96
|
|
|
100
|
-
expect(
|
|
97
|
+
expect(wrapper.emitted('update:modelValue')).toBeTruthy()
|
|
98
|
+
expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([2])
|
|
101
99
|
})
|
|
102
100
|
|
|
103
101
|
it('should render disabled buttons with length equals to 0', async () => {
|
|
104
102
|
const wrapper = mountFunction({
|
|
105
|
-
|
|
103
|
+
props: {
|
|
106
104
|
length: 0,
|
|
107
|
-
|
|
105
|
+
modelValue: 1,
|
|
108
106
|
},
|
|
109
107
|
})
|
|
110
108
|
jest.runAllTimers()
|
|
@@ -114,70 +112,85 @@ describe('VPagination.ts', () => {
|
|
|
114
112
|
|
|
115
113
|
it('should watch the value', async () => {
|
|
116
114
|
const wrapper = mountFunction({
|
|
117
|
-
|
|
115
|
+
props: {
|
|
118
116
|
length: 5,
|
|
119
|
-
|
|
117
|
+
modelValue: 1,
|
|
120
118
|
},
|
|
121
119
|
})
|
|
122
120
|
|
|
123
121
|
jest.runAllTimers()
|
|
122
|
+
await wrapper.vm.$nextTick()
|
|
124
123
|
expect(wrapper.vm.selected).toBe(1)
|
|
125
124
|
|
|
126
|
-
wrapper.setProps({
|
|
127
|
-
jest.
|
|
125
|
+
await wrapper.setProps({ modelValue: 2 })
|
|
126
|
+
jest.advanceTimersByTime(150)
|
|
127
|
+
await wrapper.vm.$nextTick()
|
|
128
128
|
expect(wrapper.vm.selected).toBe(2)
|
|
129
129
|
})
|
|
130
130
|
|
|
131
131
|
it('should only render start and end of range if length is big', async () => {
|
|
132
132
|
const wrapper = mountFunction({
|
|
133
|
-
|
|
133
|
+
props: {
|
|
134
134
|
length: 100,
|
|
135
|
+
modelValue: 1,
|
|
135
136
|
},
|
|
136
137
|
})
|
|
137
138
|
jest.runAllTimers()
|
|
138
139
|
|
|
140
|
+
await wrapper.vm.$nextTick()
|
|
141
|
+
await wrapper.vm.$nextTick()
|
|
142
|
+
jest.advanceTimersByTime(150)
|
|
143
|
+
|
|
144
|
+
// Force maxButtons to be set and trigger re-render
|
|
145
|
+
wrapper.vm.maxButtons = 5
|
|
139
146
|
await wrapper.vm.$nextTick()
|
|
140
147
|
|
|
141
148
|
expect(wrapper.html()).toMatchSnapshot()
|
|
142
|
-
expect(wrapper.findAll('.v-pagination__more')
|
|
149
|
+
expect(wrapper.findAll('.v-pagination__more')).toHaveLength(1)
|
|
143
150
|
})
|
|
144
151
|
|
|
145
152
|
it('should only render middle of range if length is big and value is somewhere in the middle', async () => {
|
|
146
153
|
const wrapper = mountFunction({
|
|
147
|
-
|
|
154
|
+
props: {
|
|
148
155
|
length: 100,
|
|
149
|
-
|
|
156
|
+
modelValue: 50,
|
|
150
157
|
},
|
|
151
158
|
})
|
|
152
159
|
jest.runAllTimers()
|
|
153
160
|
|
|
161
|
+
await wrapper.vm.$nextTick()
|
|
162
|
+
await wrapper.vm.$nextTick()
|
|
163
|
+
jest.advanceTimersByTime(150)
|
|
164
|
+
|
|
165
|
+
// Force maxButtons to be set and trigger re-render
|
|
166
|
+
wrapper.vm.maxButtons = 5
|
|
154
167
|
await wrapper.vm.$nextTick()
|
|
155
168
|
|
|
156
169
|
expect(wrapper.html()).toMatchSnapshot()
|
|
157
|
-
expect(wrapper.findAll('.v-pagination__more')
|
|
170
|
+
expect(wrapper.findAll('.v-pagination__more')).toHaveLength(2)
|
|
158
171
|
})
|
|
159
172
|
|
|
160
173
|
it('should only render start of range if value is equals "left"', async () => {
|
|
161
174
|
const wrapper = mountFunction({
|
|
162
|
-
|
|
175
|
+
props: {
|
|
163
176
|
length: 100,
|
|
164
177
|
totalVisible: 5,
|
|
165
178
|
},
|
|
166
179
|
})
|
|
167
180
|
const maxLength = Number(wrapper.vm.totalVisible)
|
|
168
181
|
const left = Math.ceil(maxLength / 2)
|
|
169
|
-
wrapper.setProps({
|
|
182
|
+
wrapper.setProps({ modelValue: left })
|
|
170
183
|
jest.runAllTimers()
|
|
171
184
|
|
|
172
185
|
await wrapper.vm.$nextTick()
|
|
173
186
|
|
|
174
187
|
expect(wrapper.html()).toMatchSnapshot()
|
|
175
|
-
expect(wrapper.findAll('.v-pagination__more')
|
|
188
|
+
expect(wrapper.findAll('.v-pagination__more')).toHaveLength(1)
|
|
176
189
|
})
|
|
177
190
|
|
|
178
191
|
it('should only render end of range if value is equals "right"', async () => {
|
|
179
192
|
const wrapper = mountFunction({
|
|
180
|
-
|
|
193
|
+
props: {
|
|
181
194
|
length: 100,
|
|
182
195
|
totalVisible: 5,
|
|
183
196
|
},
|
|
@@ -186,20 +199,20 @@ describe('VPagination.ts', () => {
|
|
|
186
199
|
const even = maxLength % 2 === 0 ? 1 : 0
|
|
187
200
|
const left = Math.ceil(maxLength / 2)
|
|
188
201
|
const right = wrapper.vm.length - left + 1 + even
|
|
189
|
-
wrapper.setProps({
|
|
202
|
+
wrapper.setProps({ modelValue: right })
|
|
190
203
|
jest.runAllTimers()
|
|
191
204
|
|
|
192
205
|
await wrapper.vm.$nextTick()
|
|
193
206
|
|
|
194
207
|
expect(wrapper.html()).toMatchSnapshot()
|
|
195
|
-
expect(wrapper.findAll('.v-pagination__more')
|
|
208
|
+
expect(wrapper.findAll('.v-pagination__more')).toHaveLength(1)
|
|
196
209
|
})
|
|
197
210
|
|
|
198
211
|
it('should use totalVisible prop if defined', async () => {
|
|
199
212
|
const wrapper = mountFunction({
|
|
200
|
-
|
|
213
|
+
props: {
|
|
201
214
|
length: 100,
|
|
202
|
-
|
|
215
|
+
modelValue: 50,
|
|
203
216
|
totalVisible: 10,
|
|
204
217
|
},
|
|
205
218
|
})
|
|
@@ -208,8 +221,8 @@ describe('VPagination.ts', () => {
|
|
|
208
221
|
await wrapper.vm.$nextTick()
|
|
209
222
|
|
|
210
223
|
expect(wrapper.html()).toMatchSnapshot()
|
|
211
|
-
expect(wrapper.findAll('.v-pagination__more')
|
|
212
|
-
expect(wrapper.findAll('.v-pagination__item')
|
|
224
|
+
expect(wrapper.findAll('.v-pagination__more')).toHaveLength(2)
|
|
225
|
+
expect(wrapper.findAll('.v-pagination__item')).toHaveLength(8)
|
|
213
226
|
})
|
|
214
227
|
|
|
215
228
|
it('should set from to 1 if <= 0', () => {
|
|
@@ -223,11 +236,10 @@ describe('VPagination.ts', () => {
|
|
|
223
236
|
// even if it's not real world, so that we can detect changes
|
|
224
237
|
it('should use parents width for on resize calculation', () => {
|
|
225
238
|
const wrapper = mount({
|
|
226
|
-
|
|
227
|
-
render: h => h('div', [h(VPagination)]),
|
|
239
|
+
render: () => h('div', [h(VPagination)]),
|
|
228
240
|
})
|
|
229
241
|
|
|
230
|
-
const pagination = wrapper.
|
|
242
|
+
const pagination = wrapper.findComponent(VPagination)
|
|
231
243
|
|
|
232
244
|
expect(pagination.vm.maxButtons).toBe(22)
|
|
233
245
|
|
|
@@ -243,7 +255,7 @@ describe('VPagination.ts', () => {
|
|
|
243
255
|
maxButtons: 4,
|
|
244
256
|
}),
|
|
245
257
|
|
|
246
|
-
|
|
258
|
+
props: {
|
|
247
259
|
length: 40,
|
|
248
260
|
totalVisible: 10,
|
|
249
261
|
},
|
|
@@ -258,13 +270,13 @@ describe('VPagination.ts', () => {
|
|
|
258
270
|
expect(wrapper.vm.items).toHaveLength(10)
|
|
259
271
|
})
|
|
260
272
|
|
|
261
|
-
it('should never show more than the number of total visible buttons', () => {
|
|
273
|
+
it('should never show more than the number of total visible buttons', async () => {
|
|
262
274
|
const wrapper = mountFunction({
|
|
263
275
|
data: () => ({
|
|
264
276
|
maxButtons: 0,
|
|
265
277
|
}),
|
|
266
278
|
|
|
267
|
-
|
|
279
|
+
props: {
|
|
268
280
|
length: 5,
|
|
269
281
|
totalVisible: undefined,
|
|
270
282
|
},
|
|
@@ -276,10 +288,12 @@ describe('VPagination.ts', () => {
|
|
|
276
288
|
|
|
277
289
|
wrapper.setData({ maxButtons: 0 })
|
|
278
290
|
wrapper.setProps({ totalVisible: 10 })
|
|
291
|
+
await wrapper.vm.$nextTick()
|
|
279
292
|
expect(wrapper.vm.items).toHaveLength(10)
|
|
280
293
|
|
|
281
294
|
wrapper.setData({ maxButtons: 11 })
|
|
282
295
|
wrapper.setProps({ totalVisible: undefined })
|
|
296
|
+
await wrapper.vm.$nextTick()
|
|
283
297
|
expect(wrapper.vm.items).toHaveLength(11)
|
|
284
298
|
|
|
285
299
|
wrapper.setData({ maxButtons: 12 })
|
|
@@ -290,7 +304,7 @@ describe('VPagination.ts', () => {
|
|
|
290
304
|
it('should return length when maxButtons is less than 1', () => {
|
|
291
305
|
const wrapper = mountFunction({
|
|
292
306
|
data: () => ({ maxButtons: -3 }),
|
|
293
|
-
|
|
307
|
+
props: { length: 4 },
|
|
294
308
|
})
|
|
295
309
|
|
|
296
310
|
expect(wrapper.vm.items).toEqual([1, 2, 3, 4])
|