@fincity/kirun-js 3.2.1 → 3.2.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.
@@ -55,3 +55,31 @@ test('ObjectValueSetterExtractor Test', async () => {
55
55
  extractor.setValue('Store.plain', 'plainString', false, false);
56
56
  expect(extractor.getValue('Store.plain')).toStrictEqual('plainString');
57
57
  });
58
+
59
+ test('ObjectValueSetterExtractor - set empty object then set nested property with numeric key', async () => {
60
+ let store = {};
61
+
62
+ let extractor: ObjectValueSetterExtractor = new ObjectValueSetterExtractor(store, 'Store');
63
+
64
+ extractor.setValue('Store.x', {});
65
+ expect(extractor.getValue('Store.x')).toMatchObject({});
66
+
67
+ extractor.setValue('Store.x.1', 'kiran');
68
+ expect(extractor.getValue('Store.x.1')).toBe('kiran');
69
+ expect(extractor.getValue('Store.x')).toMatchObject({ '1': 'kiran' });
70
+ });
71
+
72
+ test('ObjectValueSetterExtractor - set empty array then set element with numeric index', async () => {
73
+ let store = {};
74
+
75
+ let extractor: ObjectValueSetterExtractor = new ObjectValueSetterExtractor(store, 'Store');
76
+
77
+ extractor.setValue('Store.arr', []);
78
+ expect(extractor.getValue('Store.arr')).toMatchObject([]);
79
+
80
+ extractor.setValue('Store.arr.1', 'value');
81
+ expect(extractor.getValue('Store.arr.1')).toBe('value');
82
+ const arr = extractor.getValue('Store.arr');
83
+ expect(arr.length).toBe(2);
84
+ expect(arr[1]).toBe('value');
85
+ });