selectic 3.0.13 → 3.0.14

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": "selectic",
3
- "version": "3.0.13",
3
+ "version": "3.0.14",
4
4
  "description": "Smart Select for VueJS 3.x",
5
5
  "main": "dist/selectic.common.js",
6
6
  "module": "dist/selectic.esm.js",
@@ -38,7 +38,7 @@
38
38
  "test": "npm run build && tape test/**/*.spec.js"
39
39
  },
40
40
  "dependencies": {
41
- "vtyx": "4.0.4"
41
+ "vtyx": "4.0.5"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@babel/types": "^7.16.7",
@@ -860,6 +860,44 @@ tape.test('Store creation', (subT) => {
860
860
  t.deepEqual(store.state.internalValue, [2, 'hello', 1, true]);
861
861
  t.end();
862
862
  });
863
+
864
+ sTest.test('should call getItemsCallback if item is not in options', async (t) => {
865
+ const spyGetItems = {};
866
+ const store = new Store({
867
+ params: {
868
+ multiple: true,
869
+ strictValue: false,
870
+ },
871
+ getItemsCallback: buildGetItemsCb({ spy: spyGetItems}),
872
+ options: getOptions(5),
873
+ value: [2, 10, 1],
874
+ });
875
+
876
+ await sleep(0);
877
+ t.true(spyGetItems.nbCall >= 1, 'fetch callback should be called at least once');
878
+
879
+ t.deepEqual(store.state.internalValue, [2, 10, 1]);
880
+
881
+ const item = store.getItem(10);
882
+
883
+ t.deepEqual(item, {
884
+ id: 10,
885
+ text: 'some text 10',
886
+ data: 'data10',
887
+ disabled: false,
888
+ selected: true,
889
+ isGroup: false,
890
+ });
891
+
892
+ const currentOptions = store.state.allOptions;
893
+ t.is(currentOptions.length, 5, 'should add fetched items');
894
+
895
+ const hasItem10 = currentOptions.some((option) => option.id === 10);
896
+
897
+ t.false(hasItem10, 'should not add the item');
898
+
899
+ t.end();
900
+ });
863
901
  });
864
902
 
865
903
  st.test('in dynamic mode', (sTest) => {