selectic 3.1.0 → 3.1.2
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/selectic.common.js +110 -22
- package/dist/selectic.esm.js +110 -22
- package/doc/breakingChanges.md +8 -0
- package/doc/changeIcons.md +8 -2
- package/package.json +1 -1
- package/src/ExtendedList.tsx +5 -5
- package/src/Icon.tsx +2 -2
- package/src/List.tsx +0 -4
- package/src/Store.tsx +161 -25
- package/src/index.tsx +2 -2
- package/src/tools.ts +13 -0
- package/test/Store/Store_creation.spec.js +12 -12
- package/test/Store/Store_props.spec.js +612 -595
- package/test/Store/changeIcons.spec.js +1 -1
- package/test/Store/commit.spec.js +56 -47
- package/test/Store/selectGroup.spec.js +278 -271
- package/test/Store/toggleSelectAll.spec.js +6 -1
- package/test/helper.js +4 -0
- package/test/tools.js +5 -1
- package/types/ExtendedList.d.ts +5 -5
- package/types/List.d.ts +0 -3
- package/types/Store.d.ts +15 -2
- package/types/index.d.ts +2 -2
- package/types/tools.d.ts +4 -0
|
@@ -8,6 +8,9 @@ const tape = require('tape');
|
|
|
8
8
|
const StoreFile = require('../dist/Store.js');
|
|
9
9
|
const Store = StoreFile.default;
|
|
10
10
|
|
|
11
|
+
const testSingle = true;
|
|
12
|
+
const testMultiple = true;
|
|
13
|
+
|
|
11
14
|
tape.test('selectGroup()', (st) => {
|
|
12
15
|
function getStaticOptions() {
|
|
13
16
|
const group1 = getOptions(10, 'gp1-', 0, 'group1');
|
|
@@ -26,364 +29,368 @@ tape.test('selectGroup()', (st) => {
|
|
|
26
29
|
const group2Ids = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29];
|
|
27
30
|
const group3Ids = [31, 32, 33, 34, 37, 38];
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (testSingle) {
|
|
33
|
+
st.test('when "multiple" is false', (section) => {
|
|
34
|
+
section.test('with static mode', (sTest) => {
|
|
35
|
+
function getStore() {
|
|
36
|
+
const options = getStaticOptions();
|
|
37
|
+
const store = new Store({
|
|
38
|
+
options: options,
|
|
39
|
+
params: {
|
|
40
|
+
multiple: false,
|
|
41
|
+
autoSelect: false,
|
|
42
|
+
strictValue: true,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
return store;
|
|
47
|
+
}
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
sTest.test('should not change selection', async (t) => {
|
|
50
|
+
const store = getStore();
|
|
51
|
+
await _.nextVueTick(store);
|
|
52
|
+
store.commit('isOpen', true);
|
|
53
|
+
await _.sleep(0);
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
t.is(store.state.internalValue, null, 'initialization');
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
store.selectGroup('group1', true);
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
t.is(store.state.internalValue, null);
|
|
60
|
+
t.is(store.state.status.hasChanged, false);
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
/* Check if it also not changed value when there is one */
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
store.selectItem(5, true);
|
|
65
|
+
/* reset status to check that it is modified */
|
|
66
|
+
store.state.status.hasChanged = false;
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
store.selectGroup('group2', true);
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
t.is(store.state.internalValue, 5);
|
|
71
|
+
t.is(store.state.status.hasChanged, false);
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
t.end();
|
|
74
|
+
});
|
|
70
75
|
});
|
|
71
|
-
});
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
section.test('with dynamic mode', (sTest) => {
|
|
78
|
+
sTest.test('should not select any value', async (t) => {
|
|
79
|
+
const command = {};
|
|
80
|
+
const spy = {};
|
|
81
|
+
|
|
82
|
+
const store = new Store({
|
|
83
|
+
fetchCallback: buildFetchCb({
|
|
84
|
+
total: 300,
|
|
85
|
+
group: [{
|
|
86
|
+
name: 'g1',
|
|
87
|
+
offset: 0,
|
|
88
|
+
}, {
|
|
89
|
+
name: 'g2',
|
|
90
|
+
offset: 20,
|
|
91
|
+
}, {
|
|
92
|
+
name: 'g3',
|
|
93
|
+
offset: 250,
|
|
94
|
+
}],
|
|
95
|
+
command,
|
|
96
|
+
spy,
|
|
97
|
+
}),
|
|
98
|
+
groups: [{
|
|
99
|
+
id: 'g1',
|
|
100
|
+
name: 'Group 1',
|
|
84
101
|
}, {
|
|
85
|
-
|
|
86
|
-
|
|
102
|
+
id: 'g2',
|
|
103
|
+
name: 'Group 2',
|
|
87
104
|
}, {
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
id: 'g3',
|
|
106
|
+
name: 'Group 3',
|
|
90
107
|
}],
|
|
91
|
-
|
|
92
|
-
spy,
|
|
93
|
-
}),
|
|
94
|
-
groups: [{
|
|
95
|
-
id: 'g1',
|
|
96
|
-
name: 'Group 1',
|
|
97
|
-
}, {
|
|
98
|
-
id: 'g2',
|
|
99
|
-
name: 'Group 2',
|
|
100
|
-
}, {
|
|
101
|
-
id: 'g3',
|
|
102
|
-
name: 'Group 3',
|
|
103
|
-
}],
|
|
104
|
-
});
|
|
105
|
-
await _.nextVueTick(store);
|
|
106
|
-
store.commit('isOpen', true);
|
|
107
|
-
command.fetch();
|
|
108
|
-
resetCall(spy);
|
|
108
|
+
});
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
await _.nextVueTick(store);
|
|
111
|
+
store.commit('isOpen', true);
|
|
112
|
+
command.fetch();
|
|
113
|
+
resetCall(spy);
|
|
114
|
+
await _.nextVueTick(store, command.promise, _.sleep(0) /* await request resolution */);
|
|
111
115
|
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
t.is(store.state.internalValue, null, 'initialization');
|
|
117
|
+
t.is(store.state.filteredOptions[0].id, 'g1', 'initialization checks group is visible');
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
store.selectGroup('g1', true);
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
/* Currently selection is blocked for dynamic mode */
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
t.is(store.state.internalValue, null);
|
|
124
|
+
t.is(store.state.status.hasChanged, false);
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
t.end();
|
|
127
|
+
});
|
|
123
128
|
});
|
|
124
129
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
st.test('when "multiple" is true', (section) => {
|
|
128
|
-
section.test('with static mode', (sTest) => {
|
|
129
|
-
function getStore() {
|
|
130
|
-
const options = getStaticOptions();
|
|
131
|
-
const store = new Store({
|
|
132
|
-
options: options,
|
|
133
|
-
params: {
|
|
134
|
-
multiple: true,
|
|
135
|
-
strictValue: true,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
130
|
+
}
|
|
138
131
|
|
|
139
|
-
|
|
140
|
-
|
|
132
|
+
if (testMultiple) {
|
|
133
|
+
st.test('when "multiple" is true', (section) => {
|
|
134
|
+
section.test('with static mode', (sTest) => {
|
|
135
|
+
function getStore() {
|
|
136
|
+
const options = getStaticOptions();
|
|
137
|
+
const store = new Store({
|
|
138
|
+
options: options,
|
|
139
|
+
params: {
|
|
140
|
+
multiple: true,
|
|
141
|
+
strictValue: true,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
await _.nextVueTick(store);
|
|
145
|
-
store.commit('isOpen', true);
|
|
146
|
-
await _.sleep(0);
|
|
145
|
+
return store;
|
|
146
|
+
}
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
sTest.test('should select several value', async (t) => {
|
|
149
|
+
const store = getStore();
|
|
150
|
+
await _.nextVueTick(store);
|
|
151
|
+
store.commit('isOpen', true);
|
|
152
|
+
await _.sleep(0);
|
|
149
153
|
|
|
150
|
-
|
|
154
|
+
t.deepEqual(store.state.internalValue, [], 'initialization');
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
t.is(store.state.status.hasChanged, true);
|
|
156
|
+
store.selectGroup('group1', true);
|
|
154
157
|
|
|
155
|
-
|
|
158
|
+
t.deepEqual(store.state.internalValue, group1Ids);
|
|
159
|
+
t.is(store.state.status.hasChanged, true);
|
|
156
160
|
|
|
157
|
-
|
|
158
|
-
store.state.status.hasChanged = false;
|
|
161
|
+
/* it should add selection to the current selection */
|
|
159
162
|
|
|
160
|
-
|
|
163
|
+
/* reset status to check that it is modified */
|
|
164
|
+
store.state.status.hasChanged = false;
|
|
161
165
|
|
|
162
|
-
|
|
163
|
-
t.is(store.state.status.hasChanged, true);
|
|
166
|
+
store.selectGroup('group2', true);
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
t.deepEqual(store.state.internalValue, group1Ids.concat(group2Ids));
|
|
169
|
+
t.is(store.state.status.hasChanged, true);
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
await _.nextVueTick(store);
|
|
171
|
-
store.commit('isOpen', true);
|
|
172
|
-
await _.sleep(0);
|
|
171
|
+
t.end();
|
|
172
|
+
});
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
sTest.test('should not duplicate already selected values', async (t) => {
|
|
175
|
+
const store = getStore();
|
|
176
|
+
await _.nextVueTick(store);
|
|
177
|
+
store.commit('isOpen', true);
|
|
178
|
+
await _.sleep(0);
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
store.selectItem(1, true);
|
|
181
|
+
store.selectItem(6, true);
|
|
182
|
+
store.selectItem(11, true);
|
|
183
|
+
t.deepEqual(store.state.internalValue, [1, 6, 11], 'initialization');
|
|
180
184
|
|
|
181
|
-
|
|
182
|
-
t.is(store.state.status.hasChanged, true);
|
|
185
|
+
store.selectGroup('group1', true);
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
t.deepEqual(store.state.internalValue, [1, 6, 11, 0, 2, 3, 4, 5, 7, 8, 9]);
|
|
188
|
+
t.is(store.state.status.hasChanged, true);
|
|
186
189
|
|
|
187
|
-
|
|
190
|
+
/* reset status to check that it is modified */
|
|
191
|
+
store.state.status.hasChanged = false;
|
|
188
192
|
|
|
189
|
-
|
|
190
|
-
t.is(store.state.status.hasChanged, false,
|
|
191
|
-
'should not considered as changed if no new elements are added');
|
|
193
|
+
store.selectGroup('group1', true);
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
+
t.deepEqual(store.state.internalValue, [1, 6, 11, 0, 2, 3, 4, 5, 7, 8, 9]);
|
|
196
|
+
t.is(store.state.status.hasChanged, false,
|
|
197
|
+
'should not considered as changed if no new elements are added');
|
|
195
198
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
await _.nextVueTick(store);
|
|
199
|
-
store.commit('isOpen', true);
|
|
200
|
-
await _.sleep(0);
|
|
199
|
+
t.end();
|
|
200
|
+
});
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
sTest.test('should not select disabled and exclusive values', async (t) => {
|
|
203
|
+
const store = getStore();
|
|
204
|
+
await _.nextVueTick(store);
|
|
205
|
+
store.commit('isOpen', true);
|
|
206
|
+
await _.sleep(0);
|
|
203
207
|
|
|
204
|
-
|
|
208
|
+
t.deepEqual(store.state.internalValue, [], 'initialization');
|
|
205
209
|
|
|
206
|
-
|
|
207
|
-
t.is(store.state.status.hasChanged, true);
|
|
210
|
+
store.selectGroup('group3', true);
|
|
208
211
|
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
t.deepEqual(store.state.internalValue, group3Ids, 'should not contains disabled and exclusive items');
|
|
213
|
+
t.is(store.state.status.hasChanged, true);
|
|
211
214
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
await _.nextVueTick(store);
|
|
215
|
-
store.commit('isOpen', true);
|
|
216
|
-
await _.sleep(0);
|
|
217
|
-
store.selectItem(1, true);
|
|
218
|
-
store.selectItem(6, true);
|
|
219
|
-
store.selectItem(11, true);
|
|
220
|
-
store.selectGroup('group2', true);
|
|
221
|
-
store.selectItem(31, true);
|
|
215
|
+
t.end();
|
|
216
|
+
});
|
|
222
217
|
|
|
223
|
-
|
|
218
|
+
sTest.test('should unselect values', async (t) => {
|
|
219
|
+
const store = getStore();
|
|
220
|
+
await _.nextVueTick(store);
|
|
221
|
+
store.commit('isOpen', true);
|
|
222
|
+
await _.sleep(0);
|
|
223
|
+
store.selectItem(1, true);
|
|
224
|
+
store.selectItem(6, true);
|
|
225
|
+
store.selectItem(11, true);
|
|
226
|
+
store.selectGroup('group2', true);
|
|
227
|
+
store.selectItem(31, true);
|
|
224
228
|
|
|
225
|
-
|
|
229
|
+
t.deepEqual(store.state.internalValue, [1, 6, 11, 10, ...group2Ids.slice(2), 31], 'initialization');
|
|
226
230
|
|
|
227
|
-
|
|
228
|
-
t.is(store.state.status.hasChanged, true);
|
|
231
|
+
store.selectGroup('group2', false);
|
|
229
232
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
store.state.status.hasChanged = false;
|
|
233
|
+
t.deepEqual(store.state.internalValue, [1, 6, 31]);
|
|
234
|
+
t.is(store.state.status.hasChanged, true);
|
|
233
235
|
|
|
234
|
-
|
|
236
|
+
/* Remove already not selected group */
|
|
237
|
+
/* reset status to check that it is modified */
|
|
238
|
+
store.state.status.hasChanged = false;
|
|
235
239
|
|
|
236
|
-
|
|
237
|
-
t.is(store.state.status.hasChanged, false,
|
|
238
|
-
'should not considered as changed if no new elements are removed');
|
|
240
|
+
store.selectGroup('group2', false);
|
|
239
241
|
|
|
240
|
-
|
|
242
|
+
t.deepEqual(store.state.internalValue, [1, 6, 31], 'should not changed');
|
|
243
|
+
t.is(store.state.status.hasChanged, false,
|
|
244
|
+
'should not considered as changed if no new elements are removed');
|
|
241
245
|
|
|
242
|
-
|
|
246
|
+
/* should remove partial selection */
|
|
243
247
|
|
|
244
|
-
|
|
245
|
-
t.is(store.state.status.hasChanged, true);
|
|
248
|
+
store.selectGroup('group1', false);
|
|
246
249
|
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
t.deepEqual(store.state.internalValue, [31]);
|
|
251
|
+
t.is(store.state.status.hasChanged, true);
|
|
249
252
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
await _.nextVueTick(store);
|
|
253
|
-
store.commit('isOpen', true);
|
|
254
|
-
store.commit('searchText', '1');
|
|
255
|
-
store.selectItem(37, true);
|
|
256
|
-
await _.sleep(0);
|
|
253
|
+
t.end();
|
|
254
|
+
});
|
|
257
255
|
|
|
258
|
-
|
|
256
|
+
sTest.test('should apply only on filtered elements', async (t) => {
|
|
257
|
+
const store = getStore();
|
|
258
|
+
await _.nextVueTick(store);
|
|
259
|
+
store.commit('isOpen', true);
|
|
260
|
+
store.commit('searchText', '1');
|
|
261
|
+
store.selectItem(37, true);
|
|
262
|
+
await _.sleep(0);
|
|
259
263
|
|
|
260
|
-
|
|
264
|
+
t.deepEqual(store.state.internalValue, [37], 'initialization');
|
|
261
265
|
|
|
262
|
-
|
|
263
|
-
t.is(store.state.status.hasChanged, true);
|
|
266
|
+
store.selectGroup('group2', true);
|
|
264
267
|
|
|
265
|
-
|
|
268
|
+
t.deepEqual(store.state.internalValue, [37, ...group2FilteredIds]);
|
|
269
|
+
t.is(store.state.status.hasChanged, true);
|
|
266
270
|
|
|
267
|
-
|
|
268
|
-
store.state.status.hasChanged = false;
|
|
271
|
+
/* it should remove selection */
|
|
269
272
|
|
|
270
|
-
|
|
273
|
+
/* reset status to check that it is modified */
|
|
274
|
+
store.state.status.hasChanged = false;
|
|
271
275
|
|
|
272
|
-
|
|
273
|
-
t.is(store.state.status.hasChanged, true);
|
|
276
|
+
store.selectGroup('group2', false);
|
|
274
277
|
|
|
275
|
-
|
|
278
|
+
t.deepEqual(store.state.internalValue, [37]);
|
|
279
|
+
t.is(store.state.status.hasChanged, true);
|
|
276
280
|
|
|
277
|
-
|
|
281
|
+
/* it should remove only filtered selection */
|
|
278
282
|
|
|
279
|
-
|
|
280
|
-
store.state.status.hasChanged = false;
|
|
283
|
+
store.selectItem(31, true);
|
|
281
284
|
|
|
282
|
-
|
|
285
|
+
/* reset status to check that it is modified */
|
|
286
|
+
store.state.status.hasChanged = false;
|
|
283
287
|
|
|
284
|
-
|
|
285
|
-
t.is(store.state.status.hasChanged, true);
|
|
288
|
+
store.selectGroup('group3', false);
|
|
286
289
|
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
t.deepEqual(store.state.internalValue, [37]);
|
|
291
|
+
t.is(store.state.status.hasChanged, true);
|
|
289
292
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
await _.nextVueTick(store);
|
|
293
|
-
store.commit('isOpen', true);
|
|
294
|
-
await _.sleep(0);
|
|
295
|
-
|
|
296
|
-
store.selectGroup('group1', true);
|
|
297
|
-
t.is(store.state.filteredOptions[0].selected, true, 'should select the group');
|
|
298
|
-
t.is(store.state.filteredOptions[1].selected, true); // id: 0
|
|
299
|
-
t.is(store.state.filteredOptions[2].selected, true);
|
|
300
|
-
t.is(store.state.filteredOptions[3].selected, true);
|
|
301
|
-
t.is(store.state.filteredOptions[4].selected, true);
|
|
302
|
-
t.is(store.state.filteredOptions[5].selected, true);
|
|
303
|
-
t.is(store.state.filteredOptions[6].selected, true);
|
|
304
|
-
t.is(store.state.filteredOptions[7].selected, true);
|
|
305
|
-
t.is(store.state.filteredOptions[8].selected, true);
|
|
306
|
-
t.is(store.state.filteredOptions[9].selected, true);
|
|
307
|
-
t.is(store.state.filteredOptions[10].selected, true);
|
|
308
|
-
t.is(store.state.filteredOptions[11].selected, false);
|
|
309
|
-
|
|
310
|
-
store.selectItem(5, false);
|
|
311
|
-
t.is(store.state.filteredOptions[0].selected, false, 'should unselect the group');
|
|
312
|
-
t.is(store.state.filteredOptions[6].selected, false); // id: 5
|
|
313
|
-
|
|
314
|
-
t.end();
|
|
315
|
-
});
|
|
293
|
+
t.end();
|
|
294
|
+
});
|
|
316
295
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
296
|
+
sTest.test('should have set items as selected', async (t) => {
|
|
297
|
+
const store = getStore();
|
|
298
|
+
await _.nextVueTick(store);
|
|
299
|
+
store.commit('isOpen', true);
|
|
300
|
+
await _.sleep(0);
|
|
301
|
+
|
|
302
|
+
store.selectGroup('group1', true);
|
|
303
|
+
t.is(store.state.filteredOptions[0].selected, true, 'should select the group');
|
|
304
|
+
t.is(store.state.filteredOptions[1].selected, true); // id: 0
|
|
305
|
+
t.is(store.state.filteredOptions[2].selected, true);
|
|
306
|
+
t.is(store.state.filteredOptions[3].selected, true);
|
|
307
|
+
t.is(store.state.filteredOptions[4].selected, true);
|
|
308
|
+
t.is(store.state.filteredOptions[5].selected, true);
|
|
309
|
+
t.is(store.state.filteredOptions[6].selected, true);
|
|
310
|
+
t.is(store.state.filteredOptions[7].selected, true);
|
|
311
|
+
t.is(store.state.filteredOptions[8].selected, true);
|
|
312
|
+
t.is(store.state.filteredOptions[9].selected, true);
|
|
313
|
+
t.is(store.state.filteredOptions[10].selected, true);
|
|
314
|
+
t.is(store.state.filteredOptions[11].selected, false);
|
|
315
|
+
|
|
316
|
+
store.selectItem(5, false);
|
|
317
|
+
t.is(store.state.filteredOptions[0].selected, false, 'should unselect the group');
|
|
318
|
+
t.is(store.state.filteredOptions[6].selected, false); // id: 5
|
|
319
|
+
|
|
320
|
+
t.end();
|
|
321
|
+
});
|
|
322
322
|
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
sTest.test('should not close list', async (t) => {
|
|
324
|
+
const store = getStore();
|
|
325
|
+
await _.nextVueTick(store);
|
|
326
|
+
store.commit('isOpen', true);
|
|
327
|
+
await _.sleep(0);
|
|
325
328
|
|
|
326
|
-
|
|
327
|
-
|
|
329
|
+
store.selectGroup('group1', true);
|
|
330
|
+
t.is(store.state.isOpen, true);
|
|
328
331
|
|
|
329
|
-
|
|
332
|
+
store.selectItem('group1', false);
|
|
333
|
+
t.is(store.state.isOpen, true);
|
|
334
|
+
|
|
335
|
+
t.end();
|
|
336
|
+
});
|
|
330
337
|
});
|
|
331
|
-
});
|
|
332
338
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
339
|
+
section.test('with dynamic mode', (sTest) => {
|
|
340
|
+
sTest.test('should not select any value', async (t) => {
|
|
341
|
+
const command = {};
|
|
342
|
+
const spy = {};
|
|
343
|
+
|
|
344
|
+
const store = new Store({
|
|
345
|
+
params: {
|
|
346
|
+
multiple: true,
|
|
347
|
+
},
|
|
348
|
+
fetchCallback: buildFetchCb({
|
|
349
|
+
total: 300,
|
|
350
|
+
group: [{
|
|
351
|
+
name: 'g1',
|
|
352
|
+
offset: 0,
|
|
353
|
+
}, {
|
|
354
|
+
name: 'g2',
|
|
355
|
+
offset: 20,
|
|
356
|
+
}, {
|
|
357
|
+
name: 'g3',
|
|
358
|
+
offset: 250,
|
|
359
|
+
}],
|
|
360
|
+
command,
|
|
361
|
+
spy,
|
|
362
|
+
}),
|
|
363
|
+
groups: [{
|
|
364
|
+
id: 'g1',
|
|
365
|
+
name: 'Group 1',
|
|
347
366
|
}, {
|
|
348
|
-
|
|
349
|
-
|
|
367
|
+
id: 'g2',
|
|
368
|
+
name: 'Group 2',
|
|
350
369
|
}, {
|
|
351
|
-
|
|
352
|
-
|
|
370
|
+
id: 'g3',
|
|
371
|
+
name: 'Group 3',
|
|
353
372
|
}],
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
name: 'Group 1',
|
|
360
|
-
}, {
|
|
361
|
-
id: 'g2',
|
|
362
|
-
name: 'Group 2',
|
|
363
|
-
}, {
|
|
364
|
-
id: 'g3',
|
|
365
|
-
name: 'Group 3',
|
|
366
|
-
}],
|
|
367
|
-
});
|
|
368
|
-
await _.nextVueTick(store);
|
|
369
|
-
store.commit('isOpen', true);
|
|
370
|
-
command.fetch();
|
|
371
|
-
resetCall(spy);
|
|
373
|
+
});
|
|
374
|
+
await _.nextVueTick(store);
|
|
375
|
+
store.commit('isOpen', true);
|
|
376
|
+
command.fetch();
|
|
377
|
+
resetCall(spy);
|
|
372
378
|
|
|
373
|
-
|
|
379
|
+
await _.nextVueTick(store, command.promise, _.sleep(0) /* await request resolution */);
|
|
374
380
|
|
|
375
|
-
|
|
376
|
-
|
|
381
|
+
t.deepEqual(store.state.internalValue, [], 'initialization');
|
|
382
|
+
t.is(store.state.filteredOptions[0].id, 'g1', 'initialization checks group is visible');
|
|
377
383
|
|
|
378
|
-
|
|
384
|
+
store.selectGroup('g1', true);
|
|
379
385
|
|
|
380
|
-
|
|
386
|
+
/* Currently selection is blocked for dynamic mode */
|
|
381
387
|
|
|
382
|
-
|
|
383
|
-
|
|
388
|
+
t.deepEqual(store.state.internalValue, []);
|
|
389
|
+
t.is(store.state.status.hasChanged, false);
|
|
384
390
|
|
|
385
|
-
|
|
391
|
+
t.end();
|
|
392
|
+
});
|
|
386
393
|
});
|
|
387
394
|
});
|
|
388
|
-
}
|
|
395
|
+
}
|
|
389
396
|
});
|