@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,24 +1,30 @@
|
|
|
1
1
|
import Validatable from '../'
|
|
2
2
|
import {
|
|
3
3
|
mount,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
MountingOptions,
|
|
5
|
+
VueWrapper,
|
|
6
6
|
} from '@vue/test-utils'
|
|
7
7
|
import { wait } from '../../../../test'
|
|
8
|
+
import { defineComponent, h } from 'vue'
|
|
8
9
|
|
|
9
10
|
describe('validatable.ts', () => {
|
|
10
|
-
const Mock =
|
|
11
|
-
|
|
11
|
+
const Mock = defineComponent({
|
|
12
|
+
mixins: [Validatable],
|
|
13
|
+
render: () => h('div'),
|
|
12
14
|
})
|
|
13
15
|
|
|
14
|
-
type Instance = InstanceType<typeof Mock
|
|
15
|
-
let mountFunction: (
|
|
16
|
+
type Instance = InstanceType<typeof Mock>;
|
|
17
|
+
let mountFunction: (
|
|
18
|
+
options?: MountingOptions<Instance>
|
|
19
|
+
) => VueWrapper<Instance>
|
|
16
20
|
beforeEach(() => {
|
|
17
|
-
mountFunction = (options?:
|
|
21
|
+
mountFunction = (options?: MountingOptions<Instance>) => {
|
|
18
22
|
return mount(Mock, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
global: {
|
|
24
|
+
mocks: {
|
|
25
|
+
$vuetify: {
|
|
26
|
+
theme: { dark: false },
|
|
27
|
+
},
|
|
22
28
|
},
|
|
23
29
|
},
|
|
24
30
|
...options,
|
|
@@ -33,12 +39,12 @@ describe('validatable.ts', () => {
|
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
const wrapper = mountFunction({
|
|
36
|
-
provide: { form },
|
|
42
|
+
global: { provide: { form } },
|
|
37
43
|
})
|
|
38
44
|
|
|
39
45
|
expect(form.register).toHaveBeenCalled()
|
|
40
46
|
|
|
41
|
-
wrapper.
|
|
47
|
+
wrapper.unmount()
|
|
42
48
|
|
|
43
49
|
expect(form.unregister).toHaveBeenCalled()
|
|
44
50
|
})
|
|
@@ -51,45 +57,48 @@ describe('validatable.ts', () => {
|
|
|
51
57
|
wrapper.vm.resetValidation()
|
|
52
58
|
|
|
53
59
|
expect(wrapper.vm.isResetting).toBe(true)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
});
|
|
61
|
+
[true, false].forEach(returns => {
|
|
62
|
+
it(
|
|
63
|
+
'should reset valid flag on resetValidation - ' + String(returns),
|
|
64
|
+
async () => {
|
|
65
|
+
jest.useFakeTimers()
|
|
66
|
+
const wrapper = mountFunction({
|
|
67
|
+
props: {
|
|
68
|
+
rules: [() => returns || String(returns)],
|
|
69
|
+
},
|
|
70
|
+
})
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
expect(wrapper.vm.valid).toBe(returns)
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
wrapper.vm.valid = !returns
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
wrapper.vm.resetValidation()
|
|
77
|
+
await wrapper.vm.$nextTick()
|
|
78
|
+
jest.runAllTimers()
|
|
79
|
+
await wrapper.vm.$nextTick()
|
|
80
|
+
expect(wrapper.vm.valid).toBe(returns)
|
|
81
|
+
jest.useRealTimers()
|
|
82
|
+
}
|
|
83
|
+
)
|
|
75
84
|
})
|
|
76
85
|
|
|
77
86
|
/* eslint-disable-next-line max-statements */
|
|
78
|
-
it('should manually validate', () => {
|
|
87
|
+
it('should manually validate', async () => {
|
|
79
88
|
const wrapper = mountFunction()
|
|
80
89
|
|
|
81
90
|
expect(wrapper.vm.errorBucket).toEqual([])
|
|
82
91
|
|
|
83
92
|
// Function failing
|
|
84
|
-
wrapper.setProps({ rules: [() => 'fizzbuzz'] })
|
|
85
|
-
|
|
93
|
+
await wrapper.setProps({ rules: [() => 'fizzbuzz'] })
|
|
86
94
|
wrapper.vm.validate()
|
|
87
95
|
|
|
88
96
|
expect(wrapper.vm.errorBucket).toEqual(['fizzbuzz'])
|
|
89
97
|
|
|
90
|
-
// Function passing
|
|
91
|
-
wrapper.setProps({
|
|
92
|
-
|
|
98
|
+
// Function passing with proper value handling
|
|
99
|
+
await wrapper.setProps({
|
|
100
|
+
rules: [val => (val && val.length > 3) || 'fizzbuzz'],
|
|
101
|
+
})
|
|
93
102
|
wrapper.vm.validate(false, 'foo')
|
|
94
103
|
|
|
95
104
|
expect(wrapper.vm.errorBucket).toEqual(['fizzbuzz'])
|
|
@@ -99,36 +108,34 @@ describe('validatable.ts', () => {
|
|
|
99
108
|
expect(wrapper.vm.errorBucket).toEqual([])
|
|
100
109
|
|
|
101
110
|
// Boolean
|
|
102
|
-
wrapper.setProps({ rules: [false] })
|
|
103
|
-
|
|
111
|
+
await wrapper.setProps({ rules: [false] })
|
|
104
112
|
wrapper.vm.validate()
|
|
105
113
|
|
|
106
114
|
// https://github.com/vuetifyjs/vuetify/issues/9976
|
|
107
115
|
expect(wrapper.vm.errorBucket).toEqual([''])
|
|
108
116
|
|
|
109
117
|
// Boolean true sets no messages
|
|
110
|
-
wrapper.setProps({ rules: [true] })
|
|
111
|
-
|
|
118
|
+
await wrapper.setProps({ rules: [true] })
|
|
112
119
|
wrapper.vm.validate()
|
|
113
120
|
|
|
114
121
|
expect(wrapper.vm.errorBucket).toEqual([])
|
|
115
122
|
|
|
116
123
|
// String
|
|
117
|
-
wrapper.setProps({ rules: ['foobar'] })
|
|
118
|
-
|
|
124
|
+
await wrapper.setProps({ rules: ['foobar'] })
|
|
119
125
|
wrapper.vm.validate()
|
|
120
126
|
|
|
121
127
|
expect(wrapper.vm.errorBucket).toEqual(['foobar'])
|
|
122
128
|
|
|
123
129
|
// Warning
|
|
124
|
-
wrapper.setProps({ rules: [undefined] })
|
|
125
|
-
|
|
130
|
+
await wrapper.setProps({ rules: [undefined] })
|
|
126
131
|
wrapper.vm.validate()
|
|
127
132
|
|
|
128
|
-
expect(
|
|
133
|
+
expect(
|
|
134
|
+
`Rules should return a string or boolean, received 'undefined' instead`
|
|
135
|
+
).toHaveBeenWarned()
|
|
129
136
|
|
|
130
137
|
// Force validation state
|
|
131
|
-
wrapper.setProps({ rules: [false] })
|
|
138
|
+
await wrapper.setProps({ rules: [false] })
|
|
132
139
|
|
|
133
140
|
expect(wrapper.vm.hasInput).toBe(false)
|
|
134
141
|
expect(wrapper.vm.hasFocused).toBe(false)
|
|
@@ -142,210 +149,213 @@ describe('validatable.ts', () => {
|
|
|
142
149
|
// https://github.com/vuetifyjs/vuetify/issues/5362
|
|
143
150
|
it('should not validate on blur readonly or disabled when blurring', async () => {
|
|
144
151
|
const focusBlur = async wrapper => {
|
|
145
|
-
wrapper.
|
|
152
|
+
wrapper.vm.isFocused = true
|
|
153
|
+
await wrapper.vm.$nextTick()
|
|
154
|
+
wrapper.vm.isFocused = false
|
|
146
155
|
await wrapper.vm.$nextTick()
|
|
147
|
-
wrapper.setData({ isFocused: false })
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
const validate = jest.fn()
|
|
151
158
|
const wrapper = mountFunction({
|
|
152
|
-
|
|
159
|
+
props: {
|
|
153
160
|
validateOnBlur: true,
|
|
154
161
|
},
|
|
155
|
-
methods: { validate },
|
|
156
162
|
})
|
|
157
163
|
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
expect(wrapper.vm.isFocused).toBe(false)
|
|
164
|
+
// Create a mock function and replace the validate method
|
|
165
|
+
const validateSpy = jest.fn()
|
|
166
|
+
const originalValidate = wrapper.vm.validate
|
|
167
|
+
wrapper.vm.validate = validateSpy
|
|
163
168
|
|
|
169
|
+
// Normal validation
|
|
164
170
|
await focusBlur(wrapper)
|
|
165
|
-
|
|
166
|
-
expect(validate).toHaveBeenCalledTimes(2)
|
|
171
|
+
expect(validateSpy).toHaveBeenCalledTimes(1)
|
|
167
172
|
|
|
168
173
|
// Disabled - no validation
|
|
169
|
-
wrapper.setProps({ disabled: true })
|
|
174
|
+
await wrapper.setProps({ disabled: true })
|
|
175
|
+
validateSpy.mockClear()
|
|
170
176
|
|
|
171
177
|
await focusBlur(wrapper)
|
|
178
|
+
expect(validateSpy).toHaveBeenCalledTimes(0)
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
wrapper.setProps({ disabled: false })
|
|
180
|
+
// Re-enable validation
|
|
181
|
+
await wrapper.setProps({ disabled: false })
|
|
182
|
+
validateSpy.mockClear()
|
|
177
183
|
|
|
178
184
|
await focusBlur(wrapper)
|
|
185
|
+
expect(validateSpy).toHaveBeenCalledTimes(1)
|
|
179
186
|
|
|
180
|
-
|
|
187
|
+
// Restore original method
|
|
188
|
+
wrapper.vm.validate = originalValidate
|
|
181
189
|
})
|
|
182
190
|
|
|
183
|
-
it('should have success', () => {
|
|
191
|
+
it('should have success', async () => {
|
|
184
192
|
const wrapper = mountFunction()
|
|
185
193
|
|
|
186
194
|
expect(wrapper.vm.hasSuccess).toBe(false)
|
|
187
195
|
|
|
188
|
-
wrapper.setProps({ success: true })
|
|
189
|
-
|
|
196
|
+
await wrapper.setProps({ success: true })
|
|
190
197
|
expect(wrapper.vm.hasSuccess).toBe(true)
|
|
191
198
|
|
|
192
|
-
wrapper.setProps({ success: false, successMessages: ['foobar'] })
|
|
193
|
-
|
|
199
|
+
await wrapper.setProps({ success: false, successMessages: ['foobar'] })
|
|
194
200
|
expect(wrapper.vm.hasSuccess).toBe(true)
|
|
195
201
|
|
|
196
|
-
wrapper.setProps({ successMessages: [] })
|
|
197
|
-
|
|
202
|
+
await wrapper.setProps({ successMessages: [] })
|
|
198
203
|
expect(wrapper.vm.hasSuccess).toBe(false)
|
|
199
204
|
|
|
200
|
-
wrapper.setProps({ successMessages: null })
|
|
201
|
-
|
|
205
|
+
await wrapper.setProps({ successMessages: null })
|
|
202
206
|
expect(wrapper.vm.hasSuccess).toBe(false)
|
|
203
207
|
})
|
|
204
208
|
|
|
205
209
|
/* eslint-disable-next-line max-statements */
|
|
206
|
-
it('should have messages', () => {
|
|
210
|
+
it('should have messages', async () => {
|
|
207
211
|
const wrapper = mountFunction()
|
|
208
212
|
|
|
209
213
|
expect(wrapper.vm.hasMessages).toBe(false)
|
|
210
214
|
|
|
211
215
|
// Null message
|
|
212
|
-
wrapper.setProps({ messages: null })
|
|
216
|
+
await wrapper.setProps({ messages: null })
|
|
213
217
|
expect(wrapper.vm.hasMessages).toBe(false)
|
|
214
218
|
|
|
215
219
|
// String message
|
|
216
|
-
wrapper.setProps({ messages: 'foo' })
|
|
220
|
+
await wrapper.setProps({ messages: 'foo' })
|
|
217
221
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
218
222
|
|
|
219
223
|
// Array message
|
|
220
|
-
wrapper.setProps({ messages: ['foo'] })
|
|
224
|
+
await wrapper.setProps({ messages: ['foo'] })
|
|
221
225
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
222
|
-
wrapper.setProps({ messages: [] }) // Reset
|
|
226
|
+
await wrapper.setProps({ messages: [] }) // Reset
|
|
223
227
|
|
|
224
228
|
// Null error
|
|
225
|
-
wrapper.setProps({ errorMessages: null })
|
|
229
|
+
await wrapper.setProps({ errorMessages: null })
|
|
226
230
|
expect(wrapper.vm.hasMessages).toBe(false)
|
|
227
231
|
|
|
228
232
|
// String error
|
|
229
|
-
wrapper.setProps({ errorMessages: 'bar' })
|
|
233
|
+
await wrapper.setProps({ errorMessages: 'bar' })
|
|
230
234
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
231
235
|
|
|
232
236
|
// Array error
|
|
233
|
-
wrapper.setProps({ errorMessages: ['bar'] })
|
|
237
|
+
await wrapper.setProps({ errorMessages: ['bar'] })
|
|
234
238
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
235
|
-
wrapper.setProps({ errorMessages: [] }) // Reset
|
|
239
|
+
await wrapper.setProps({ errorMessages: [] }) // Reset
|
|
236
240
|
|
|
237
241
|
// Null success
|
|
238
|
-
wrapper.setProps({ successMessages: null })
|
|
242
|
+
await wrapper.setProps({ successMessages: null })
|
|
239
243
|
expect(wrapper.vm.hasMessages).toBe(false)
|
|
240
244
|
|
|
241
245
|
// String success
|
|
242
|
-
wrapper.setProps({ successMessages: 'fizz' })
|
|
246
|
+
await wrapper.setProps({ successMessages: 'fizz' })
|
|
243
247
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
244
248
|
|
|
245
249
|
// Array success
|
|
246
|
-
wrapper.setProps({ successMessages: ['fizz'] })
|
|
250
|
+
await wrapper.setProps({ successMessages: ['fizz'] })
|
|
247
251
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
248
|
-
wrapper.setProps({ successMessages: [] }) // Reset
|
|
252
|
+
await wrapper.setProps({ successMessages: [] }) // Reset
|
|
249
253
|
|
|
250
254
|
// Error bucket
|
|
251
|
-
wrapper.setProps({ rules: [() => 'fizzbuzz'] })
|
|
255
|
+
await wrapper.setProps({ rules: [() => 'fizzbuzz'] })
|
|
252
256
|
expect(wrapper.vm.shouldValidate).toBe(false)
|
|
253
257
|
|
|
254
|
-
wrapper.
|
|
258
|
+
wrapper.vm.hasInput = true
|
|
259
|
+
await wrapper.vm.$nextTick()
|
|
255
260
|
|
|
256
261
|
expect(wrapper.vm.shouldValidate).toBe(true)
|
|
257
262
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
258
263
|
|
|
259
|
-
wrapper.
|
|
264
|
+
wrapper.vm.hasInput = false
|
|
265
|
+
wrapper.vm.hasFocused = true
|
|
266
|
+
await wrapper.vm.$nextTick()
|
|
260
267
|
|
|
261
268
|
expect(wrapper.vm.shouldValidate).toBe(true)
|
|
262
269
|
expect(wrapper.vm.hasMessages).toBe(true)
|
|
263
270
|
|
|
264
|
-
wrapper.
|
|
271
|
+
wrapper.vm.isResetting = true
|
|
272
|
+
await wrapper.vm.$nextTick()
|
|
265
273
|
|
|
266
274
|
expect(wrapper.vm.shouldValidate).toBe(false)
|
|
267
275
|
|
|
268
|
-
wrapper.
|
|
269
|
-
wrapper.setProps({ validateOnBlur: true })
|
|
276
|
+
wrapper.vm.isResetting = false
|
|
277
|
+
await wrapper.setProps({ validateOnBlur: true })
|
|
270
278
|
|
|
271
279
|
expect(wrapper.vm.shouldValidate).toBe(true)
|
|
272
280
|
})
|
|
273
281
|
|
|
274
|
-
it('should have state', () => {
|
|
282
|
+
it('should have state', async () => {
|
|
275
283
|
const wrapper = mountFunction()
|
|
276
284
|
|
|
277
285
|
expect(wrapper.vm.hasState).toBe(false)
|
|
278
286
|
|
|
279
|
-
wrapper.setProps({ success: true })
|
|
280
|
-
|
|
287
|
+
await wrapper.setProps({ success: true })
|
|
281
288
|
expect(wrapper.vm.hasState).toBe(true)
|
|
282
289
|
|
|
283
|
-
wrapper.setProps({ success: false, error: true })
|
|
284
|
-
|
|
290
|
+
await wrapper.setProps({ success: false, error: true })
|
|
291
|
+
await wrapper.vm.$nextTick()
|
|
285
292
|
expect(wrapper.vm.hasState).toBe(true)
|
|
286
293
|
|
|
287
|
-
wrapper.setProps({ error: false })
|
|
288
|
-
|
|
294
|
+
await wrapper.setProps({ error: false })
|
|
295
|
+
await wrapper.vm.$nextTick()
|
|
289
296
|
expect(wrapper.vm.hasState).toBe(false)
|
|
290
297
|
})
|
|
291
298
|
|
|
292
|
-
it('should return validation state', () => {
|
|
299
|
+
it('should return validation state', async () => {
|
|
293
300
|
const wrapper = mountFunction()
|
|
294
301
|
|
|
295
302
|
expect(wrapper.vm.validationState).toBeUndefined()
|
|
296
303
|
|
|
297
|
-
wrapper.setProps({ error: true })
|
|
304
|
+
await wrapper.setProps({ error: true })
|
|
298
305
|
expect(wrapper.vm.validationState).toBe('error')
|
|
299
306
|
|
|
300
|
-
wrapper.setProps({ error: false, success: true })
|
|
307
|
+
await wrapper.setProps({ error: false, success: true })
|
|
301
308
|
expect(wrapper.vm.validationState).toBe('success')
|
|
302
309
|
|
|
303
|
-
wrapper.setProps({ success: false
|
|
304
|
-
wrapper.
|
|
310
|
+
await wrapper.setProps({ success: false })
|
|
311
|
+
await wrapper.vm.$nextTick()
|
|
312
|
+
await wrapper.setProps({ color: 'blue' })
|
|
313
|
+
wrapper.vm.hasColor = true
|
|
314
|
+
await wrapper.vm.$nextTick()
|
|
305
315
|
expect(wrapper.vm.validationState).toBe('blue')
|
|
306
316
|
})
|
|
307
317
|
|
|
308
|
-
it('should return a sliced amount based on error count', () => {
|
|
318
|
+
it('should return a sliced amount based on error count', async () => {
|
|
309
319
|
const wrapper = mountFunction({
|
|
310
|
-
|
|
311
|
-
errorMessages: [
|
|
312
|
-
'foobar',
|
|
313
|
-
'fizzbuzz',
|
|
314
|
-
],
|
|
320
|
+
props: {
|
|
321
|
+
errorMessages: ['foobar', 'fizzbuzz'],
|
|
315
322
|
},
|
|
316
323
|
})
|
|
317
324
|
|
|
318
325
|
expect(wrapper.vm.validations).toHaveLength(1)
|
|
319
326
|
|
|
320
|
-
wrapper.setProps({ errorCount: 2 })
|
|
321
|
-
|
|
327
|
+
await wrapper.setProps({ errorCount: 2 })
|
|
322
328
|
expect(wrapper.vm.validations).toHaveLength(2)
|
|
323
329
|
})
|
|
324
330
|
|
|
325
331
|
it('should validate when internalValue changes', async () => {
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
const wrapper = mountFunction()
|
|
333
|
+
|
|
334
|
+
// Create a mock function and replace the validate method
|
|
335
|
+
const validateSpy = jest.fn()
|
|
336
|
+
const originalValidate = wrapper.vm.validate
|
|
337
|
+
wrapper.vm.validate = validateSpy
|
|
330
338
|
|
|
331
339
|
expect(wrapper.vm.hasInput).toBe(false)
|
|
332
|
-
wrapper.setProps({ value: 'foo' })
|
|
333
340
|
|
|
334
|
-
//
|
|
341
|
+
// Simulate internal value change
|
|
342
|
+
wrapper.vm.internalValue = 'foo'
|
|
343
|
+
await wrapper.vm.$nextTick()
|
|
335
344
|
await wrapper.vm.$nextTick()
|
|
336
345
|
|
|
337
346
|
expect(wrapper.vm.hasInput).toBe(true)
|
|
338
|
-
expect(
|
|
347
|
+
expect(validateSpy).toHaveBeenCalled()
|
|
348
|
+
|
|
349
|
+
// Restore original method
|
|
350
|
+
wrapper.vm.validate = originalValidate
|
|
339
351
|
})
|
|
340
352
|
|
|
341
353
|
it('should update values when resetting after timeout', async () => {
|
|
342
354
|
const wrapper = mountFunction()
|
|
343
355
|
|
|
344
|
-
wrapper.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
isResetting: true,
|
|
348
|
-
})
|
|
356
|
+
wrapper.vm.hasInput = true
|
|
357
|
+
wrapper.vm.hasFocused = true
|
|
358
|
+
wrapper.vm.isResetting = true
|
|
349
359
|
|
|
350
360
|
expect(wrapper.vm.hasInput).toBe(true)
|
|
351
361
|
expect(wrapper.vm.hasFocused).toBe(true)
|
|
@@ -365,25 +375,23 @@ describe('validatable.ts', () => {
|
|
|
365
375
|
it('should emit error update when value changes and shouldValidate', async () => {
|
|
366
376
|
const wrapper = mountFunction()
|
|
367
377
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
wrapper.vm.$on('update:error', onError)
|
|
371
|
-
|
|
372
|
-
wrapper.setProps({ error: true })
|
|
373
|
-
|
|
378
|
+
// Set up conditions for shouldValidate to be true
|
|
379
|
+
wrapper.vm.hasInput = true
|
|
374
380
|
await wrapper.vm.$nextTick()
|
|
375
381
|
|
|
376
|
-
wrapper.setProps({ error:
|
|
382
|
+
await wrapper.setProps({ error: true })
|
|
383
|
+
await wrapper.vm.$nextTick()
|
|
377
384
|
|
|
385
|
+
await wrapper.setProps({ error: false })
|
|
378
386
|
await wrapper.vm.$nextTick()
|
|
379
387
|
|
|
380
|
-
expect(
|
|
388
|
+
expect(wrapper.emitted('update:error')).toBeTruthy()
|
|
381
389
|
})
|
|
382
390
|
|
|
383
391
|
it('should reset validation and internalValue', async () => {
|
|
384
392
|
const wrapper = mountFunction({
|
|
385
|
-
|
|
386
|
-
|
|
393
|
+
props: {
|
|
394
|
+
modelValue: 'foobar',
|
|
387
395
|
},
|
|
388
396
|
})
|
|
389
397
|
|
|
@@ -392,65 +400,87 @@ describe('validatable.ts', () => {
|
|
|
392
400
|
expect(wrapper.vm.isResetting).toBe(true)
|
|
393
401
|
expect(wrapper.vm.internalValue).toBeNull()
|
|
394
402
|
|
|
395
|
-
wrapper.setProps({
|
|
396
|
-
|
|
403
|
+
await wrapper.setProps({ modelValue: ['foobar'] })
|
|
397
404
|
await wrapper.vm.$nextTick()
|
|
398
405
|
|
|
399
406
|
wrapper.vm.reset()
|
|
400
407
|
expect(wrapper.vm.isResetting).toBe(true)
|
|
408
|
+
|
|
409
|
+
// Wait for the reset watcher to process
|
|
410
|
+
await wrapper.vm.$nextTick()
|
|
411
|
+
await wait()
|
|
401
412
|
expect(wrapper.vm.internalValue).toEqual([])
|
|
402
413
|
})
|
|
403
414
|
|
|
404
415
|
// https://github.com/vuetifyjs/vuetify/issues/6025
|
|
405
|
-
it('should accept null for external messages', () => {
|
|
416
|
+
it('should accept null for external messages', async () => {
|
|
406
417
|
const wrapper = mountFunction({
|
|
407
|
-
|
|
418
|
+
props: {
|
|
408
419
|
errorMessages: ['Foobar'],
|
|
409
420
|
},
|
|
410
421
|
})
|
|
411
422
|
|
|
412
423
|
expect(wrapper.vm.externalError).toBe(true)
|
|
413
424
|
|
|
414
|
-
wrapper.setProps({ errorMessages: [] })
|
|
425
|
+
await wrapper.setProps({ errorMessages: [] })
|
|
415
426
|
expect(wrapper.vm.externalError).toBe(false)
|
|
416
427
|
|
|
417
|
-
wrapper.setProps({ errorMessages: 'Fizzbuzz' })
|
|
428
|
+
await wrapper.setProps({ errorMessages: 'Fizzbuzz' })
|
|
418
429
|
expect(wrapper.vm.externalError).toBe(true)
|
|
419
430
|
|
|
420
|
-
wrapper.setProps({ errorMessages: null })
|
|
431
|
+
await wrapper.setProps({ errorMessages: null })
|
|
432
|
+
await wrapper.vm.$nextTick()
|
|
421
433
|
expect(wrapper.vm.externalError).toBe(false)
|
|
422
434
|
})
|
|
423
435
|
|
|
424
|
-
it('should return white when no color and isDark', () => {
|
|
436
|
+
it('should return white when no color and isDark', async () => {
|
|
425
437
|
const wrapper = mountFunction({
|
|
426
|
-
|
|
427
|
-
|
|
438
|
+
global: {
|
|
439
|
+
mocks: {
|
|
440
|
+
$vuetify: {
|
|
441
|
+
theme: { dark: false },
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
computed: {
|
|
445
|
+
appIsDark: () => false,
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
props: { dark: true },
|
|
428
449
|
})
|
|
429
450
|
|
|
430
451
|
expect(wrapper.vm.computedColor).toBe('white')
|
|
431
452
|
|
|
432
|
-
wrapper.setProps({ color: 'blue' })
|
|
453
|
+
await wrapper.setProps({ color: 'blue' })
|
|
433
454
|
expect(wrapper.vm.computedColor).toBe('blue')
|
|
434
455
|
|
|
435
|
-
wrapper.setProps({ color: undefined, dark: undefined })
|
|
456
|
+
await wrapper.setProps({ color: undefined, dark: undefined })
|
|
436
457
|
expect(wrapper.vm.computedColor).toBe('primary')
|
|
437
458
|
|
|
438
459
|
const wrapper2 = mountFunction({
|
|
439
|
-
|
|
460
|
+
global: {
|
|
461
|
+
mocks: {
|
|
462
|
+
$vuetify: {
|
|
463
|
+
theme: { dark: true },
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
computed: {
|
|
467
|
+
appIsDark: () => true,
|
|
468
|
+
},
|
|
469
|
+
},
|
|
440
470
|
})
|
|
441
471
|
|
|
442
472
|
expect(wrapper2.vm.computedColor).toBe('primary')
|
|
443
473
|
|
|
444
|
-
wrapper2.setProps({ color: 'blue' })
|
|
474
|
+
await wrapper2.setProps({ color: 'blue' })
|
|
445
475
|
expect(wrapper2.vm.computedColor).toBe('blue')
|
|
446
476
|
|
|
447
|
-
wrapper2.setProps({ color: undefined, light: true })
|
|
477
|
+
await wrapper2.setProps({ color: undefined, light: true })
|
|
448
478
|
expect(wrapper2.vm.computedColor).toBe('primary')
|
|
449
479
|
})
|
|
450
480
|
|
|
451
481
|
it('should return undefined for color and validation state if disabled', () => {
|
|
452
482
|
const wrapper = mountFunction({
|
|
453
|
-
|
|
483
|
+
props: {
|
|
454
484
|
color: 'blue',
|
|
455
485
|
dark: true,
|
|
456
486
|
disabled: true,
|
|
@@ -465,31 +495,37 @@ describe('validatable.ts', () => {
|
|
|
465
495
|
// https://github.com/vuetifyjs/vuetify/issues/10174
|
|
466
496
|
it('should validate correct value when blurring', async () => {
|
|
467
497
|
const wrapper = mountFunction({
|
|
468
|
-
|
|
498
|
+
props: {
|
|
469
499
|
rules: [v => !!v || 'Mandatory Field'],
|
|
470
500
|
validateOnBlur: true,
|
|
471
|
-
|
|
501
|
+
modelValue: 'Foo',
|
|
472
502
|
},
|
|
473
503
|
})
|
|
474
504
|
|
|
475
|
-
wrapper.
|
|
505
|
+
wrapper.vm.isFocused = true
|
|
506
|
+
await wrapper.vm.$nextTick()
|
|
476
507
|
|
|
477
|
-
wrapper.setProps({
|
|
508
|
+
await wrapper.setProps({ modelValue: '' })
|
|
478
509
|
await wrapper.vm.$nextTick()
|
|
479
510
|
|
|
480
|
-
wrapper.
|
|
511
|
+
wrapper.vm.isFocused = false
|
|
512
|
+
await wrapper.vm.$nextTick()
|
|
481
513
|
await wrapper.vm.$nextTick()
|
|
482
514
|
|
|
483
515
|
expect(wrapper.vm.hasError).toBe(true)
|
|
484
516
|
|
|
485
|
-
wrapper.
|
|
517
|
+
wrapper.vm.isFocused = true
|
|
518
|
+
await wrapper.vm.$nextTick()
|
|
486
519
|
|
|
487
|
-
wrapper.setProps({
|
|
520
|
+
await wrapper.setProps({ modelValue: 'Bar' })
|
|
488
521
|
await wrapper.vm.$nextTick()
|
|
489
522
|
|
|
490
|
-
wrapper.
|
|
523
|
+
wrapper.vm.isFocused = false
|
|
491
524
|
await wrapper.vm.$nextTick()
|
|
492
525
|
|
|
526
|
+
// Wait for validation to complete
|
|
527
|
+
await wrapper.vm.$nextTick()
|
|
528
|
+
await wrapper.vm.$nextTick()
|
|
493
529
|
expect(wrapper.vm.hasError).toBe(false)
|
|
494
530
|
})
|
|
495
531
|
})
|