@dimailn/vuetify 2.7.2-alpha54 → 2.7.2-alpha55

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.
@@ -0,0 +1,118 @@
1
+ // Components
2
+ import VSelect from '../VSelect'
3
+
4
+ // Utilities
5
+ import {
6
+ mount,
7
+ VueWrapper,
8
+ enableAutoUnmount
9
+ } from '@vue/test-utils'
10
+ import { h } from 'vue'
11
+
12
+ const statusItems = [{ text: 'Новый', value: 'new' }]
13
+
14
+ const baseProps = {
15
+ items: statusItems,
16
+ modelValue: 'new',
17
+ placeholder: 'Выберите статус',
18
+ label: ''
19
+ }
20
+
21
+ describe('VSelect placeholder при value', () => {
22
+ type Instance = InstanceType<typeof VSelect>
23
+ let mountFunction: (options?: object) => VueWrapper<Instance>
24
+ let el: HTMLDivElement
25
+
26
+ beforeEach(() => {
27
+ mountFunction = (options = {}) => {
28
+ el = document.createElement('div')
29
+ el.setAttribute('data-app', 'true')
30
+ document.body.appendChild(el)
31
+
32
+ return mount(VSelect, {
33
+ global: {
34
+ mocks: {
35
+ $vuetify: {
36
+ lang: {
37
+ t: (val: string) => val
38
+ },
39
+ theme: {
40
+ dark: false
41
+ },
42
+ icons: {
43
+ component: 'mdi'
44
+ }
45
+ }
46
+ }
47
+ },
48
+ attachTo: el,
49
+ ...options
50
+ })
51
+ }
52
+ })
53
+
54
+ afterEach(() => {
55
+ if (el?.parentNode) {
56
+ document.body.removeChild(el)
57
+ }
58
+ })
59
+
60
+ enableAutoUnmount(afterEach)
61
+
62
+ function textInput (wrapper: VueWrapper<Instance>) {
63
+ return wrapper.find('input[type="text"]')
64
+ }
65
+
66
+ it('при value: isDirty и текст выбора корректны', () => {
67
+ const wrapper = mountFunction({ props: baseProps })
68
+
69
+ expect(wrapper.vm.isDirty).toBe(true)
70
+ expect(wrapper.find('.v-select__selection--comma').text()).toBe('Новый')
71
+ })
72
+
73
+ it('при value: на text-input нет атрибута placeholder', () => {
74
+ const wrapper = mountFunction({ props: baseProps })
75
+ const input = textInput(wrapper)
76
+
77
+ expect(input.exists()).toBe(true)
78
+ expect(input.attributes('placeholder')).toBeUndefined()
79
+ })
80
+
81
+ it('при пустом value: placeholder на text-input есть', () => {
82
+ const wrapper = mountFunction({
83
+ props: {
84
+ ...baseProps,
85
+ modelValue: null
86
+ }
87
+ })
88
+ const input = textInput(wrapper)
89
+
90
+ expect(wrapper.vm.isDirty).toBe(false)
91
+ expect(input.attributes('placeholder')).toBe('Выберите статус')
92
+ })
93
+
94
+ it('со слотом #selection при value: placeholder на input отсутствует', () => {
95
+ const wrapper = mountFunction({
96
+ props: baseProps,
97
+ slots: {
98
+ selection: ({ item }: { item: { text: string } }) => h('span', item.text)
99
+ }
100
+ })
101
+ const input = textInput(wrapper)
102
+
103
+ expect(wrapper.text()).toContain('Новый')
104
+ expect(input.attributes('placeholder')).toBeUndefined()
105
+ })
106
+
107
+ it('при persistentPlaceholder и value: placeholder на input отсутствует', () => {
108
+ const wrapper = mountFunction({
109
+ props: {
110
+ ...baseProps,
111
+ persistentPlaceholder: true
112
+ }
113
+ })
114
+ const input = textInput(wrapper)
115
+
116
+ expect(input.attributes('placeholder')).toBeUndefined()
117
+ })
118
+ })