@farm-investimentos/front-mfe-components 15.5.5 → 15.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "15.5.5",
3
+ "version": "15.6.1",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -20,10 +20,16 @@ const styles = {
20
20
  vForm: {
21
21
  maxWidth: '480px',
22
22
  },
23
+ dynamicField: {
24
+ display: 'flex',
25
+ },
23
26
  footer: {
24
27
  display: 'flex',
25
28
  justifyContent: 'end',
26
29
  },
30
+ footerMargin: {
31
+ marginTop: '16px',
32
+ },
27
33
  };
28
34
 
29
35
  export const Primary = () => ({
@@ -141,6 +147,79 @@ export const Secondary = () => ({
141
147
  `,
142
148
  });
143
149
 
150
+ export const WithDynamicFields = () => ({
151
+ data() {
152
+ return {
153
+ form: {
154
+ document: null,
155
+ name: null,
156
+ checkbox: null,
157
+ birthDate: '',
158
+ selectId: null,
159
+ rangeDate: [],
160
+ dynamics: [],
161
+ },
162
+ validForm: true,
163
+ rules: {
164
+ required: value => !!value || 'Campo obrigatório',
165
+ checked: value => !!value || 'Deve estar marcado',
166
+ },
167
+ items: [
168
+ { value: null, text: '' },
169
+ { value: 1, text: 'label 1' },
170
+ { value: 2, text: 'label 2' },
171
+ ],
172
+ styles,
173
+ };
174
+ },
175
+ methods: {
176
+ addDynamic() {
177
+ const dynamic = {
178
+ name2: '',
179
+ selectId2: null,
180
+ };
181
+ this.form.dynamics.push({ ...dynamic });
182
+ this.$refs.form.restart();
183
+ },
184
+ removeDynamic(index) {
185
+ this.form.dynamics.splice(index, 1);
186
+ this.$refs.form.restart();
187
+ },
188
+ },
189
+ template: `
190
+ <div>
191
+ <farm-btn @click="addDynamic">Add field</farm-btn>
192
+
193
+ <farm-form v-model="validForm" :style="[styles.vForm]" ref="form">
194
+ <farm-label :required="true">Nome</farm-label>
195
+ <farm-textfield-v2 v-model="form.name" :rules="[rules.required]" />
196
+
197
+ <farm-label :required="true">Select</farm-label>
198
+ <farm-select :rules="[rules.required]" :items="items" v-model="form.selectId"/>
199
+
200
+ <div :style="[styles.dynamicField]" v-for="(dynamic, index) in form.dynamics">
201
+ <div>
202
+ <farm-label :key="index + 'label'" :required="true">Dynamic</farm-label>
203
+ <farm-textfield-v2 :key="index" v-model="dynamic.name2" :rules="[rules.required]" />
204
+ </div>
205
+
206
+ <farm-icon @click="removeDynamic(index)">delete</farm-icon>
207
+ </div>
208
+
209
+ Is valid form: {{ validForm }}
210
+
211
+ <farm-line />
212
+
213
+ <footer class="footer" :style="[styles.footer, styles.footerMargin]">
214
+ <farm-btn outlined @click="$refs.form.restart()" class="mr-3">Restart</farm-btn>
215
+ <farm-btn outlined @click="$refs.form.restartValidation()" class="mr-3">Restart Validation</farm-btn>
216
+ <farm-btn outlined @click="$refs.form.reset()" class="mr-3">Reset</farm-btn>
217
+ <farm-btn :disabled="!validForm">Salvar</farm-btn>
218
+ </footer>
219
+ </farm-form>
220
+ </div>`,
221
+ });
222
+
144
223
  export const InitInvalid = () => ({
145
224
  data() {
146
225
  return {
@@ -2,7 +2,7 @@
2
2
  <form class="farm-form"><slot></slot></form>
3
3
  </template>
4
4
  <script lang="ts">
5
- import { onMounted, reactive, ref, getCurrentInstance, defineComponent } from 'vue';
5
+ import { onMounted, ref, getCurrentInstance, defineComponent } from 'vue';
6
6
 
7
7
  type ErrorsBag = Record<number, boolean>;
8
8
 
@@ -14,13 +14,13 @@ export default defineComponent({
14
14
  inheritAttrs: true,
15
15
  setup(props, { emit }) {
16
16
  const innerValue = ref(props.value);
17
- let errorsBag = reactive({} as ErrorsBag);
17
+ let errorsBag = ref({} as ErrorsBag);
18
18
  let validationFields = [];
19
19
  const instance = getCurrentInstance().proxy;
20
20
 
21
21
  const dispatchError = () => {
22
- const keys = Object.keys(errorsBag);
23
- const errorsIds = keys.filter(key => !errorsBag[key]);
22
+ const keys = Object.keys(errorsBag.value);
23
+ const errorsIds = keys.filter(key => !errorsBag.value[key]);
24
24
  emit('input', errorsIds.length === 0);
25
25
  };
26
26
 
@@ -28,7 +28,7 @@ export default defineComponent({
28
28
  field.$watch(
29
29
  'hasError',
30
30
  () => {
31
- errorsBag[field._uid] = field.valid;
31
+ errorsBag.value[field._uid] = field.valid;
32
32
  dispatchError();
33
33
  },
34
34
  { immediate: true }
@@ -67,7 +67,7 @@ export default defineComponent({
67
67
 
68
68
  const restartValidation = () => {
69
69
  validationFields = [];
70
- errorsBag = {};
70
+ errorsBag.value = {};
71
71
  recursiveFormField(instance);
72
72
  validationFields.forEach(field => {
73
73
  watchInput(field);
@@ -78,10 +78,14 @@ export default defineComponent({
78
78
 
79
79
  const restart = () => {
80
80
  validationFields = [];
81
- errorsBag = {};
82
- recursiveFormField(instance);
83
- validationFields.forEach(field => {
84
- watchInput(field);
81
+ errorsBag.value = {};
82
+
83
+ instance.$nextTick(() => {
84
+ recursiveFormField(instance);
85
+
86
+ validationFields.forEach(field => {
87
+ watchInput(field);
88
+ });
85
89
  });
86
90
  };
87
91
 
@@ -1,14 +1,76 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import Form from '../Form';
3
+ import { formWithChildrenFactory, getDeepErrorsBag } from './helpers';
3
4
 
4
5
  describe('Form component', () => {
5
- let wrapper;
6
+ let wrapper, component;
6
7
 
7
8
  beforeEach(() => {
8
9
  wrapper = shallowMount(Form);
10
+ component = wrapper.vm;
9
11
  });
10
12
 
11
13
  test('Created hook', () => {
12
14
  expect(wrapper).toBeDefined();
13
15
  });
16
+
17
+ describe('errors bag', () => {
18
+ beforeEach(() => {
19
+ const helper = formWithChildrenFactory(Form);
20
+
21
+ wrapper = helper.wrapper;
22
+ component = helper.component;
23
+ });
24
+
25
+ it('should have errors bag after mount form', () => {
26
+ const { errorsBag, errorsBagLength } = getDeepErrorsBag(component);
27
+
28
+ expect(component.errorsBag).toStrictEqual(errorsBag.value);
29
+ expect(Object.keys(component.errorsBag).length).toBe(errorsBagLength);
30
+ });
31
+
32
+ it('should update errors bag after change validatable items', async () => {
33
+ const { errorsBag, errorsBagLength } = getDeepErrorsBag(component);
34
+
35
+ expect(component.errorsBag).toStrictEqual(errorsBag.value);
36
+ expect(Object.keys(component.errorsBag).length).toBe(errorsBagLength);
37
+
38
+ await component.addDynamic();
39
+ await component.restart();
40
+
41
+ const { errorsBag: plusOneErrorsBag, errorsBagLength: plusOneErrorsBagLength } =
42
+ getDeepErrorsBag(component);
43
+
44
+ expect(Object.keys(component.errorsBag).length).toBe(plusOneErrorsBagLength);
45
+ expect(component.errorsBag).toStrictEqual(plusOneErrorsBag.value);
46
+
47
+ await component.removeDynamic(1);
48
+ await component.restart();
49
+
50
+ const { errorsBag: minusOneErrorsBag, errorsBagLength: minusOneErrorsBagLength } =
51
+ getDeepErrorsBag(component);
52
+
53
+ expect(Object.keys(component.errorsBag).length).toBe(minusOneErrorsBagLength);
54
+ expect(component.errorsBag).toStrictEqual(minusOneErrorsBag.value);
55
+ });
56
+ });
57
+
58
+ describe('isValidForm', () => {
59
+ let isValidForm;
60
+
61
+ beforeEach(() => {
62
+ const helper = formWithChildrenFactory(Form);
63
+
64
+ wrapper = helper.wrapper;
65
+ component = helper.component;
66
+ isValidForm = helper.isValidForm;
67
+ });
68
+
69
+ it('should be invalid until all validatable fields are valid', () => {
70
+ const { errorsBag } = getDeepErrorsBag(component);
71
+
72
+ expect(isValidForm.value).toBeFalsy();
73
+ expect(Object.values(errorsBag.value)).toEqual([false, false, false]);
74
+ });
75
+ });
14
76
  });
@@ -0,0 +1,106 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { ref } from 'vue';
3
+
4
+ export const errorsBag = ref({});
5
+
6
+ export function getDeepErrorsBag($node) {
7
+ const getDeep = $node => {
8
+ $node.$children.forEach($leaf => {
9
+ if ($leaf.validate) {
10
+ errorsBag.value[$leaf._uid] = $leaf.valid;
11
+ } else if ($leaf.$children.length > 1) {
12
+ getDeep($leaf);
13
+ } else if ($leaf.$children[0] && $leaf.$children[0].validate) {
14
+ errorsBag.value[$leaf.$children[0]._uid] = $leaf.$children[0].valid;
15
+ } else if ($leaf.validatable) {
16
+ errorsBag.value[$leaf._uid] = $leaf.valid;
17
+ } else {
18
+ getDeep($leaf);
19
+ }
20
+ });
21
+ };
22
+
23
+ getDeep($node);
24
+
25
+ return {
26
+ errorsBag,
27
+ errorsBagLength: errorsBag.value ? Object.keys(errorsBag.value).length : 0,
28
+ };
29
+ }
30
+
31
+ export function resetErrorsBag() {
32
+ errorsBag.value = {};
33
+ }
34
+
35
+ function mountSlot() {
36
+ const normalComponent = {
37
+ props: {
38
+ form: {
39
+ type: Object,
40
+ required: true,
41
+ },
42
+ },
43
+ template: `
44
+ <div>
45
+ <farm-textfield-v2 :rules=[rules.required] />
46
+ <farm-textfield-v2 :rules=[rules.required] />
47
+ <farm-textfield-v2 :rules=[rules.required] />
48
+
49
+ section id="dynamics">
50
+ <farm-textfield-v2 v-for="(dynamic, index) in form?.dynamics" :key="index" :name="'dynamic-' + index" />
51
+ </section>
52
+ </div>
53
+ `,
54
+ };
55
+
56
+ return {
57
+ normalComponent,
58
+ };
59
+ }
60
+
61
+ export function formWithChildrenFactory(formComponent) {
62
+ resetErrorsBag();
63
+
64
+ const { normalComponent } = mountSlot();
65
+
66
+ const form = ref({
67
+ dynamics: [],
68
+ });
69
+ const isValidForm = ref(false);
70
+
71
+ const wrapper = mount(formComponent, {
72
+ propsData: {
73
+ value: isValidForm,
74
+ },
75
+ slots: {
76
+ default: '<normal-component :form="form" />',
77
+ },
78
+ mocks: {
79
+ form,
80
+ rules: {
81
+ required: value => !!value || 'Campo obrigatório',
82
+ },
83
+ addDynamic() {
84
+ form.value.dynamics.push({
85
+ name: '',
86
+ });
87
+
88
+ return form.value.dynamics;
89
+ },
90
+ removeDynamic(index) {
91
+ form.value.dynamics.splice(index, 1);
92
+
93
+ return form.value.dynamics;
94
+ },
95
+ },
96
+ stubs: {
97
+ 'normal-component': normalComponent,
98
+ },
99
+ });
100
+
101
+ return {
102
+ isValidForm,
103
+ wrapper,
104
+ component: wrapper.vm,
105
+ };
106
+ }
@@ -8,62 +8,75 @@
8
8
  display: flex;
9
9
  align-items: center;
10
10
 
11
+ .farm-icon,
12
+ .farm-typography {
13
+ color: var(--farm-neutral-darken);
14
+ }
15
+
11
16
  &--clickable {
12
17
  cursor: pointer;
13
18
  }
14
19
 
15
- > a {
16
- text-decoration: none;
20
+ &--disabled {
21
+ cursor: default;
22
+
23
+ .farm-icon,
24
+ .farm-typography {
25
+ color: var(--farm-stroke-disabled);
26
+ }
17
27
  }
18
28
 
19
- .farm-icon,
20
- .farm-typography {
21
- color: var(--farm-neutral-darken);
29
+ > a {
30
+ text-decoration: none;
22
31
  }
23
32
 
24
33
  &:hover,
25
34
  &:focus {
26
35
  border-radius: 5px;
27
36
 
28
- @each $color in $theme-colors-list {
29
- &#{'.farm-listitem--' + $color + '-base'} {
30
- background-color: rgba(themeColor($color), 0.27);
31
- .farm-icon,
32
- .farm-typography {
33
- color: rgba(themeColor($color), 1);
37
+ &:not(.farm-listitem--disabled) {
38
+ @each $color in $theme-colors-list {
39
+ &#{'.farm-listitem--' + $color + '-base'} {
40
+ background-color: rgba(themeColor($color), 0.27);
41
+ .farm-icon,
42
+ .farm-typography {
43
+ color: rgba(themeColor($color), 1);
44
+ }
34
45
  }
35
- }
36
46
 
37
- &#{'.farm-listitem--' + $color + '-lighten'} {
38
- background-color: rgba(themeColor($color, 'lighten'), 0.27);
39
- .farm-icon,
40
- .farm-typography {
41
- color: rgba(themeColor($color), 1);
47
+ &#{'.farm-listitem--' + $color + '-lighten'} {
48
+ background-color: rgba(themeColor($color, 'lighten'), 0.27);
49
+ .farm-icon,
50
+ .farm-typography {
51
+ color: rgba(themeColor($color), 1);
52
+ }
42
53
  }
43
- }
44
54
 
45
- &#{'.farm-listitem--' + $color + '-darken'} {
46
- background-color: rgba(themeColor($color, 'darken'), 0.27);
47
- .farm-icon,
48
- .farm-typography {
49
- color: rgba(themeColor($color), 1);
55
+ &#{'.farm-listitem--' + $color + '-darken'} {
56
+ background-color: rgba(themeColor($color, 'darken'), 0.27);
57
+ .farm-icon,
58
+ .farm-typography {
59
+ color: rgba(themeColor($color), 1);
60
+ }
50
61
  }
51
62
  }
52
63
  }
53
64
  }
54
65
 
55
66
  &:active {
56
- @each $color in $theme-colors-list {
57
- &#{'.farm-listitem--' + $color + '-base'} {
58
- background-color: rgba(themeColor($color), 0.8);
59
- }
67
+ &:not(.farm-listitem--disabled) {
68
+ @each $color in $theme-colors-list {
69
+ &#{'.farm-listitem--' + $color + '-base'} {
70
+ background-color: rgba(themeColor($color), 0.8);
71
+ }
60
72
 
61
- &#{'.farm-listitem--' + $color + '-lighten'} {
62
- background-color: rgba(themeColor($color, 'lighten'), 0.8);
63
- }
73
+ &#{'.farm-listitem--' + $color + '-lighten'} {
74
+ background-color: rgba(themeColor($color, 'lighten'), 0.8);
75
+ }
64
76
 
65
- &#{'.farm-listitem--' + $color + '-darken'} {
66
- background-color: rgba(themeColor($color, 'darken'), 0.8);
77
+ &#{'.farm-listitem--' + $color + '-darken'} {
78
+ background-color: rgba(themeColor($color, 'darken'), 0.8);
79
+ }
67
80
  }
68
81
  }
69
82
  }
@@ -28,19 +28,19 @@
28
28
  margin-right: 8px;
29
29
  }
30
30
 
31
- :deep(.farm-listitem:hover .farm-typography) {
31
+ :deep(.farm-listitem:not(.farm-listitem--disabled):hover .farm-typography) {
32
32
  color: var(--farm-primary-base);
33
33
  }
34
34
 
35
- :deep(.farm-listitem:focus .farm-typography) {
35
+ :deep(.farm-listitem:not(.farm-listitem--disabled):focus .farm-typography) {
36
36
  color: var(--farm-primary-base);
37
37
  }
38
38
 
39
- :deep(.farm-listitem:hover .farm-checkbox .farm-icon) {
39
+ :deep(.farm-listitem:not(.farm-listitem--disabled):hover .farm-checkbox .farm-icon) {
40
40
  color: var(--farm-primary-lighten);
41
41
  }
42
42
 
43
- :deep(.farm-listitem:focus .farm-checkbox .farm-icon) {
43
+ :deep(.farm-listitem:not(.farm-listitem--disabled):focus .farm-checkbox .farm-icon) {
44
44
  color: var(--farm-primary-lighten);
45
45
  }
46
46
 
@@ -10,7 +10,8 @@ export default {
10
10
  description: {
11
11
  component: `Select<br />
12
12
  selector: <em>farm-select</em><br />
13
- <span style="color: var(--farm-primary-base);">ready for use</span>
13
+ <span style="color: var(--farm-primary-base);">ready for use</span><br />
14
+ <a href="https://github.com/Farm-Investimentos/front-mfe-components/blob/develop/src/components/Select/Select.vue" target="_blank">Github</a>
14
15
  `,
15
16
  },
16
17
  },
@@ -129,6 +130,42 @@ export const Disabled = () => ({
129
130
  </div>`,
130
131
  });
131
132
 
133
+ export const DisabledKeys = () => ({
134
+ data() {
135
+ return {
136
+ v: null,
137
+ items: [
138
+ { value: 1, text: ' value 1', disabled: true },
139
+ { value: 2, text: ' value 2', disabled: true },
140
+ { value: 3, text: ' value 3' },
141
+ ],
142
+ };
143
+ },
144
+ methods: {
145
+ allowAllOptions() {
146
+ this.items = [
147
+ { value: 1, text: ' value 1' },
148
+ { value: 2, text: ' value 2' },
149
+ { value: 3, text: ' value 3' },
150
+ ];
151
+ },
152
+ reset() {
153
+ this.items = [
154
+ { value: 1, text: ' value 1', disabled: true },
155
+ { value: 2, text: ' value 2', disabled: true },
156
+ { value: 3, text: ' value 3' },
157
+ ];
158
+ },
159
+ },
160
+ template: `<div style="width: 480px">
161
+ <farm-select v-model="v" :items="items" />
162
+ v-model: {{ v }}
163
+ <br><br>
164
+ <farm-btn @click="allowAllOptions">Habilitar todos itens</farm-btn>
165
+ <farm-btn @click="reset">Resetar</farm-btn>
166
+ </div>`,
167
+ });
168
+
132
169
  export const Validate = () => ({
133
170
  data() {
134
171
  return {
@@ -13,16 +13,24 @@
13
13
  v-if="!readonly && !disabled"
14
14
  :id="customId"
15
15
  >
16
- <farm-contextmenu bottom v-model="isVisible" :stay-open="multiple" ref="contextmenu">
16
+ <farm-contextmenu
17
+ bottom
18
+ v-model="isVisible"
19
+ :stay-open="multiple || clickedDisabledItem"
20
+ ref="contextmenu"
21
+ >
17
22
  <farm-list v-if="!readonly" ref="listRef" @keydown="onKeyDown">
18
23
  <farm-listitem
19
- tabindex="0"
20
24
  v-for="(item, index) in items"
25
+ tabindex="0"
21
26
  clickable
22
- hoverColorVariation="lighten"
23
- hover-color="primary"
27
+ hover-color-variation="lighten"
28
+ :hover-color="item.disabled ? 'neutral' : 'primary'"
24
29
  :key="'contextmenu_item_' + index"
25
- :class="{ 'farm-listitem--selected': item[itemValue] === innerValue }"
30
+ :class="{
31
+ 'farm-listitem--selected': item[itemValue] === innerValue,
32
+ 'farm-listitem--disabled': item.disabled,
33
+ }"
26
34
  @click="selectItem(item)"
27
35
  >
28
36
  <farm-checkbox
@@ -30,6 +38,7 @@
30
38
  v-model="checked"
31
39
  value="1"
32
40
  size="sm"
41
+ :disabled="item.disabled"
33
42
  v-if="isChecked(item)"
34
43
  />
35
44
  <farm-checkbox
@@ -37,6 +46,7 @@
37
46
  v-model="checked"
38
47
  value="2"
39
48
  size="sm"
49
+ :disabled="item.disabled"
40
50
  v-else-if="multiple"
41
51
  />
42
52
  <farm-caption bold tag="span">{{ item[itemText] }}</farm-caption>
@@ -242,6 +252,7 @@ export default defineComponent({
242
252
  keys,
243
253
  } = buildData(props);
244
254
 
255
+ const clickedDisabledItem = ref(false);
245
256
  const listRef = ref();
246
257
 
247
258
  const contextmenu = ref(null);
@@ -339,7 +350,20 @@ export default defineComponent({
339
350
  };
340
351
 
341
352
  const selectItem = item => {
342
- inputField.value.focus();
353
+ if (inputField.value) {
354
+ inputField.value.focus();
355
+ }
356
+
357
+ if (item.disabled) {
358
+ clickedDisabledItem.value = true;
359
+
360
+ // "Schedule" execution to next loop, so the contextMenu won't close immediately if a disabled item is clicked
361
+ setTimeout(() => {
362
+ clickedDisabledItem.value = false;
363
+ });
364
+ return;
365
+ }
366
+
343
367
  if (multiple.value) {
344
368
  const alreadyAdded = multipleValues.value.findIndex(
345
369
  val => val === item[itemValue.value]
@@ -457,6 +481,7 @@ export default defineComponent({
457
481
  customId,
458
482
  showErrorText,
459
483
  contextmenu,
484
+ clickedDisabledItem,
460
485
  validate,
461
486
  reset,
462
487
  selectItem,
@@ -1,6 +1,11 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
2
  import Select from '../Select';
3
3
 
4
+ /* jest.spyOn(global, 'setTimeout').mockImplementation(fn => {
5
+ fn();
6
+ return setTimeout(() => 1, 0);
7
+ }); */
8
+
4
9
  describe('Select component', () => {
5
10
  let wrapper;
6
11
  let component;
@@ -124,6 +129,66 @@ describe('Select component', () => {
124
129
  expect(component.selectedText).toBe('value 0 (+2 outros)');
125
130
  });
126
131
  });
132
+ describe('disabled items', () => {
133
+ it('should not select a disabled item', async () => {
134
+ const items = [
135
+ { value: 0, text: 'value 0', disabled: true },
136
+ { value: 1, text: 'value 1' },
137
+ { value: 2, text: 'value 2' },
138
+ { value: 3, text: 'value 3' },
139
+ ];
140
+
141
+ await wrapper.setProps({
142
+ items,
143
+ value: 1,
144
+ });
145
+
146
+ expect(component.innerValue).toBe(1);
147
+ expect(component.selectedText).toBe('value 1');
148
+ component.selectItem(items[2]);
149
+ setTimeout(() => {
150
+ expect(component.innerValue).toBe(2);
151
+ expect(component.selectedText).toBe('value 2');
152
+ }, 150);
153
+ component.selectItem(items[0]);
154
+ setTimeout(() => {
155
+ expect(component.innerValue).toBe(2);
156
+ expect(component.selectedText).toBe('value 2');
157
+ }, 150);
158
+ component.selectItem(items[3]);
159
+ setTimeout(() => {
160
+ expect(component.innerValue).toBe(3);
161
+ expect(component.selectedText).toBe('value 3');
162
+ }, 150);
163
+ });
164
+ it('should not select a disabled item if is multiple', async () => {
165
+ const items = [
166
+ { value: 0, text: 'value 0' },
167
+ { value: 1, text: 'value 1', disabled: true },
168
+ { value: 2, text: 'value 2' },
169
+ { value: 3, text: 'value 3', disabled: true },
170
+ ];
171
+
172
+ await wrapper.setProps({
173
+ multiple: true,
174
+ items,
175
+ value: [0],
176
+ });
177
+
178
+ expect(component.innerValue).toEqual([0]);
179
+ expect(component.selectedText).toBe('value 0');
180
+ component.selectItem(items[2]);
181
+ setTimeout(() => {
182
+ expect(component.innerValue).toEqual([0, 2]);
183
+ expect(component.selectedText).toBe('value 0 (+1 outro)');
184
+ }, 150);
185
+ component.selectItem(items[1]);
186
+ setTimeout(() => {
187
+ expect(component.innerValue).toEqual([0, 2]);
188
+ expect(component.selectedText).toBe('value 0 (+1 outro)');
189
+ }, 150);
190
+ });
191
+ });
127
192
 
128
193
  describe('onKeyDown', () => {
129
194
  it('should open the ContextMenu and click on current element', () => {