@qrvey/utils 1.1.2 → 1.1.6

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.
Files changed (128) hide show
  1. package/README.md +196 -143
  2. package/dist/cjs/constants/COLUMN_PROPERTY_VALUE.js +1 -1
  3. package/dist/cjs/date/constants/DATE_VALUES.js +1 -1
  4. package/dist/cjs/filters/adapters/FDToFlatUI.js +2 -1
  5. package/dist/cjs/filters/adapters/FDToUI.js +2 -1
  6. package/dist/cjs/filters/adapters/UIToFlatUI.js +2 -1
  7. package/dist/cjs/filters/adapters/UIToOldLogic.js +2 -1
  8. package/dist/cjs/filters/adapters/adaptFilterValues.d.ts +8 -0
  9. package/dist/cjs/filters/adapters/adaptFilterValues.js +18 -0
  10. package/dist/cjs/filters/adapters/flatUIToFD.js +2 -1
  11. package/dist/cjs/filters/adapters/flatUIToUI.js +2 -1
  12. package/dist/cjs/filters/adapters/logicToFlatUI.js +0 -3
  13. package/dist/cjs/filters/helpers/common/getFilterColumnLabel.js +1 -1
  14. package/dist/cjs/filters/helpers/common/getFiltersByParams.js +1 -1
  15. package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
  16. package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.js +13 -0
  17. package/dist/cjs/filters/helpers/ui/index.d.ts +1 -0
  18. package/dist/cjs/filters/helpers/ui/index.js +1 -0
  19. package/dist/cjs/filters/interfaces/common/IFSValueRelativeDate.d.ts +1 -1
  20. package/dist/cjs/general/array/filterNestedTree.d.ts +5 -2
  21. package/dist/cjs/general/array/filterNestedTree.js +13 -5
  22. package/dist/cjs/general/mix/isEmpty.js +3 -1
  23. package/dist/cjs/general/mix/isNull.js +1 -1
  24. package/dist/cjs/general/mix/randomId.d.ts +6 -3
  25. package/dist/cjs/general/mix/randomId.js +24 -7
  26. package/dist/cjs/general/mix/size.d.ts +5 -5
  27. package/dist/cjs/general/mix/size.js +9 -6
  28. package/dist/cjs/general/object/get.d.ts +1 -1
  29. package/dist/cjs/general/object/getAttribute.d.ts +9 -2
  30. package/dist/cjs/general/object/getAttribute.js +39 -8
  31. package/dist/cjs/general/object/hasProperty.d.ts +1 -1
  32. package/dist/cjs/general/object/hasProperty.js +10 -2
  33. package/dist/cjs/general/object/index.d.ts +1 -0
  34. package/dist/cjs/general/object/index.js +1 -0
  35. package/dist/cjs/general/object/isObject.js +1 -1
  36. package/dist/cjs/general/object/objectCopy.d.ts +7 -0
  37. package/dist/cjs/general/object/objectCopy.js +32 -0
  38. package/dist/cjs/general/string/capitalize.d.ts +3 -3
  39. package/dist/cjs/general/string/capitalize.js +6 -3
  40. package/dist/cjs/qrvey/getPropertyLabel.d.ts +2 -0
  41. package/dist/cjs/qrvey/getPropertyLabel.js +14 -0
  42. package/dist/cjs/qrvey/index.d.ts +1 -0
  43. package/dist/cjs/qrvey/index.js +1 -0
  44. package/dist/constants/COLUMN_PROPERTY_VALUE.js +2 -2
  45. package/dist/date/constants/DATE_VALUES.js +1 -1
  46. package/dist/filters/adapters/FDToFlatUI.js +2 -1
  47. package/dist/filters/adapters/FDToUI.js +2 -1
  48. package/dist/filters/adapters/UIToFlatUI.js +2 -1
  49. package/dist/filters/adapters/UIToOldLogic.js +2 -1
  50. package/dist/filters/adapters/adaptFilterValues.d.ts +8 -0
  51. package/dist/filters/adapters/adaptFilterValues.js +14 -0
  52. package/dist/filters/adapters/flatUIToFD.js +2 -1
  53. package/dist/filters/adapters/flatUIToUI.js +2 -1
  54. package/dist/filters/adapters/logicToFlatUI.js +0 -3
  55. package/dist/filters/helpers/common/getFilterColumnLabel.js +2 -2
  56. package/dist/filters/helpers/common/getFiltersByParams.js +1 -1
  57. package/dist/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
  58. package/dist/filters/helpers/ui/getFilterPropertyLabel.js +9 -0
  59. package/dist/filters/helpers/ui/index.d.ts +1 -0
  60. package/dist/filters/helpers/ui/index.js +1 -0
  61. package/dist/filters/interfaces/common/IFSValueRelativeDate.d.ts +1 -1
  62. package/dist/general/array/filterNestedTree.d.ts +5 -2
  63. package/dist/general/array/filterNestedTree.js +13 -5
  64. package/dist/general/mix/isEmpty.js +3 -1
  65. package/dist/general/mix/isNull.js +1 -1
  66. package/dist/general/mix/randomId.d.ts +6 -3
  67. package/dist/general/mix/randomId.js +24 -7
  68. package/dist/general/mix/size.d.ts +5 -5
  69. package/dist/general/mix/size.js +9 -6
  70. package/dist/general/object/get.d.ts +1 -1
  71. package/dist/general/object/getAttribute.d.ts +9 -2
  72. package/dist/general/object/getAttribute.js +39 -8
  73. package/dist/general/object/hasProperty.d.ts +1 -1
  74. package/dist/general/object/hasProperty.js +8 -0
  75. package/dist/general/object/index.d.ts +1 -0
  76. package/dist/general/object/index.js +1 -0
  77. package/dist/general/object/isObject.js +1 -1
  78. package/dist/general/object/objectCopy.d.ts +7 -0
  79. package/dist/general/object/objectCopy.js +28 -0
  80. package/dist/general/string/capitalize.d.ts +3 -3
  81. package/dist/general/string/capitalize.js +6 -3
  82. package/dist/qrvey/getPropertyLabel.d.ts +2 -0
  83. package/dist/qrvey/getPropertyLabel.js +10 -0
  84. package/dist/qrvey/index.d.ts +1 -0
  85. package/dist/qrvey/index.js +1 -0
  86. package/package.json +1 -1
  87. package/src/constants/COLUMN_PROPERTY_VALUE.ts +2 -2
  88. package/src/date/constants/DATE_VALUES.ts +1 -1
  89. package/src/filters/adapters/FDToFlatUI.ts +2 -1
  90. package/src/filters/adapters/FDToUI.ts +2 -0
  91. package/src/filters/adapters/UIToFlatUI.ts +2 -1
  92. package/src/filters/adapters/UIToOldLogic.ts +2 -1
  93. package/src/filters/adapters/adaptFilterValues.ts +17 -0
  94. package/src/filters/adapters/flatUIToFD.ts +2 -1
  95. package/src/filters/adapters/flatUIToUI.ts +2 -1
  96. package/src/filters/adapters/logicToFlatUI.ts +0 -3
  97. package/src/filters/helpers/backend/getAggFiltersBySummaryIndex.ts +1 -1
  98. package/src/filters/helpers/common/getFilterColumnLabel.ts +2 -2
  99. package/src/filters/helpers/common/getFiltersByParams.ts +1 -1
  100. package/src/filters/helpers/ui/getFilterPropertyLabel.ts +11 -0
  101. package/src/filters/helpers/ui/index.ts +1 -0
  102. package/src/filters/interfaces/common/IFSValueRelativeDate.ts +1 -1
  103. package/src/general/array/filterNestedTree.ts +13 -4
  104. package/src/general/mix/getTag.ts +1 -1
  105. package/src/general/mix/isEmpty.ts +3 -1
  106. package/src/general/mix/isNull.ts +1 -1
  107. package/src/general/mix/randomId.ts +24 -7
  108. package/src/general/mix/size.ts +10 -6
  109. package/src/general/object/get.ts +1 -1
  110. package/src/general/object/getAttribute.ts +47 -9
  111. package/src/general/object/hasProperty.ts +10 -1
  112. package/src/general/object/index.ts +1 -0
  113. package/src/general/object/isObject.ts +1 -1
  114. package/src/general/object/objectCopy.ts +35 -0
  115. package/src/general/string/capitalize.ts +7 -3
  116. package/src/qrvey/getPropertyLabel.ts +9 -0
  117. package/src/qrvey/index.ts +1 -0
  118. package/test/general/array/filterNestedTree.test.js +115 -0
  119. package/test/general/mix/getTag.test.js +101 -0
  120. package/test/general/mix/isEmpty.test.js +24 -24
  121. package/test/general/mix/isNull.test.js +72 -0
  122. package/test/general/mix/randomId.test.js +134 -0
  123. package/test/general/mix/size.test.js +87 -0
  124. package/test/general/object/cloneDeep.test.js +8 -16
  125. package/test/general/object/getAttribute.test.js +316 -0
  126. package/test/general/object/hasProperty.test.js +103 -0
  127. package/test/general/object/objectCopy.test.js +105 -0
  128. package/test/general/string/capitalize.test.js +87 -0
@@ -1,4 +1,4 @@
1
- const { cloneDeep, isEmpty, _hasProperty } = require('../../../dist/cjs');
1
+ const { cloneDeep } = require('../../../dist/cjs');
2
2
 
3
3
  describe('Returning an undefined with empty variables', function () {
4
4
  const empty1 = undefined;
@@ -131,21 +131,13 @@ describe('Problems creating a new object reference with inner objects and functi
131
131
  test('An object with inner objects', function () {
132
132
  const cDObject1 = cloneDeep(object1);
133
133
 
134
- const emptyA = _hasProperty(cDObject1, 'a');
135
- const emptyB = isEmpty(cDObject1.b);
136
- const emptyC = isEmpty(cDObject1.c);
137
- const emptyD1 = cDObject1.d instanceof Date;
138
- const emptyD2 = Date.parse(cDObject1.d);
139
- const emptyE = isEmpty(cDObject1.e);
140
- const emptyF = isEmpty(cDObject1.f);
141
-
142
- expect(emptyA).toBeFalsy();
143
- expect(emptyB).toBeTruthy();
144
- expect(emptyC).toBeTruthy();
145
- expect(emptyD1).toBeFalsy();
146
- expect(emptyD2).toBeTruthy();
147
- expect(emptyE).toBeTruthy();
148
- expect(emptyF).toBeTruthy();
134
+ expect(cDObject1).not.toHaveProperty('a');
135
+ expect(cDObject1.b).toBeNull();
136
+ expect(cDObject1.c).toBeNull();
137
+ expect(cDObject1.d instanceof Date).toBeFalsy();
138
+ expect(Date.parse(cDObject1.d)).toBe(Date.parse(object1.d));
139
+ expect(cDObject1.e).toBeUndefined();
140
+ expect(cDObject1.f).toBeUndefined();
149
141
 
150
142
  expect(cDObject1).not.toEqual(object1);
151
143
  });
@@ -0,0 +1,316 @@
1
+ const { getAttribute } = require('../../../dist/cjs');
2
+
3
+ const obj = {
4
+ api_key: "2Wo1LiLW4uiAiJ9FU6BphNEjxTqQNc5aPhCnpkL6",
5
+ customTokens: { sample: Array(2) },
6
+ LoadStyles: false,
7
+ appid: "D_64XzSNz",
8
+ domain: "https://postdev1.qrveyapp.com",
9
+ QRVEYID: "5LtRi43_qt",
10
+ };
11
+
12
+ describe('Testing with empty arguments', function () {
13
+ const empty1 = undefined;
14
+ const empty2 = null;
15
+ const empty3 = [];
16
+ const empty4 = {};
17
+ const empty5 = '';
18
+
19
+ test('No arguments', function () {
20
+ const empty = getAttribute();
21
+ expect(empty).toBeUndefined();
22
+ });
23
+
24
+ test('Undefined variable', function () {
25
+ const empty = getAttribute(empty1);
26
+ expect(empty).toBeUndefined();
27
+ });
28
+
29
+ test('Null variable', function () {
30
+ const empty = getAttribute(empty2);
31
+ expect(empty).toBeUndefined();
32
+ });
33
+
34
+ test('Empty Array variable', function () {
35
+ const empty = getAttribute(empty3);
36
+ expect(empty).toBeUndefined();
37
+ });
38
+
39
+ test('Empty Object variable', function () {
40
+ const empty = getAttribute(empty4);
41
+ expect(empty).toBeUndefined();
42
+ });
43
+
44
+ test('Empty String variable', function () {
45
+ const empty = getAttribute(empty5);
46
+ expect(empty).toBeUndefined();
47
+ });
48
+
49
+ test('Undefined variable with Key', function () {
50
+ const empty = getAttribute(empty1, 'appid');
51
+ expect(empty).toBeUndefined();
52
+ });
53
+
54
+ test('Null variable with Key', function () {
55
+ const empty = getAttribute(empty2, 'appid');
56
+ expect(empty).toBeUndefined();
57
+ });
58
+
59
+ test('Empty Array variable with Key', function () {
60
+ const empty = getAttribute(empty3, 'appid');
61
+ expect(empty).toBeUndefined();
62
+ });
63
+
64
+ test('Empty Object variable with Key', function () {
65
+ const empty = getAttribute(empty4, 'appid');
66
+ expect(empty).toBeUndefined();
67
+ });
68
+
69
+ test('Empty String variable with Key', function () {
70
+ const empty = getAttribute(empty5, 'appid');
71
+ expect(empty).toBeUndefined();
72
+ });
73
+
74
+ test('Undefined key argument', function () {
75
+ const empty = getAttribute(obj, empty1);
76
+ expect(empty).toBeUndefined();
77
+ });
78
+
79
+ test('Empty key argument', function () {
80
+ const empty = getAttribute(obj, empty5);
81
+ expect(empty).toBeUndefined();
82
+ });
83
+ });
84
+
85
+ describe('Testing with different argument type', function () {
86
+ const variable1 = 'Hello World';
87
+ const variable2 = 1;
88
+ const variable3 = true;
89
+ const variable4 = new Date();
90
+
91
+ test('String variable', function () {
92
+ const empty = getAttribute(variable1, variable1);
93
+ expect(empty).toBeUndefined();
94
+ });
95
+
96
+ test('Numeric variable', function () {
97
+ const empty = getAttribute(variable2, variable1);
98
+ expect(empty).toBeUndefined();
99
+ });
100
+
101
+ test('Boolean variable', function () {
102
+ const empty = getAttribute(variable3, variable1);
103
+ expect(empty).toBeUndefined();
104
+ });
105
+
106
+ test('Date variable', function () {
107
+ const empty = getAttribute(variable4, variable1);
108
+ expect(empty).toBeUndefined();
109
+ });
110
+
111
+ test('Numeric-type key', function () {
112
+ const empty = getAttribute(obj, variable2);
113
+ expect(empty).toBeUndefined();
114
+ });
115
+
116
+ test('boolean-type key', function () {
117
+ const empty = getAttribute(obj, variable3);
118
+ expect(empty).toBeUndefined();
119
+ });
120
+
121
+ test('Date-type key', function () {
122
+ const empty = getAttribute(obj, variable4);
123
+ expect(empty).toBeUndefined();
124
+ });
125
+ });
126
+
127
+
128
+ describe('Retrieving attribute by key', function () {
129
+ const lowerAttribute1 = 'app_id';
130
+ const lowerAttribute2 = 'appId';
131
+ const lowerAttribute3 = 'appid';
132
+ const lowerAttribute4 = 'AppId';
133
+ const lowerAttribute5 = 'APPID';
134
+
135
+ const snakeAttribute1 = 'api_key';
136
+ const snakeAttribute2 = 'apiKey';
137
+ const snakeAttribute3 = 'apikey';
138
+ const snakeAttribute4 = 'ApiKey';
139
+ const snakeAttribute5 = 'APIKEY';
140
+
141
+ const upperAttribute1 = 'qrvey_id';
142
+ const upperAttribute2 = 'qrveyId';
143
+ const upperAttribute3 = 'qrveyid';
144
+ const upperAttribute4 = 'QrveyId';
145
+ const upperAttribute5 = 'QRVEYID';
146
+
147
+ const camelAttribute1 = 'custom_tokens';
148
+ const camelAttribute2 = 'customTokens';
149
+ const camelAttribute3 = 'customtokens';
150
+ const camelAttribute4 = 'CustomTokens';
151
+ const camelAttribute5 = 'CUSTOMTOKENS';
152
+
153
+ const pascalAttribute1 = 'load_styles';
154
+ const pascalAttribute2 = 'loadStyles';
155
+ const pascalAttribute3 = 'loadstyles';
156
+ const pascalAttribute4 = 'LoadStyles';
157
+ const pascalAttribute5 = 'LOADSTYLES';
158
+
159
+
160
+ test('Lower attribute with snake_case key', function () {
161
+ const attribute = getAttribute(obj, lowerAttribute1);
162
+ expect(attribute).toEqual(obj[lowerAttribute3]);
163
+ });
164
+
165
+ test('Lower attribute with camelCase key', function () {
166
+ const attribute = getAttribute(obj, lowerAttribute2);
167
+ expect(attribute).toEqual(obj[lowerAttribute3]);
168
+ });
169
+
170
+ test('Lower attribute with lowercase key', function () {
171
+ const attribute = getAttribute(obj, lowerAttribute3);
172
+ expect(attribute).toEqual(obj[lowerAttribute3]);
173
+ });
174
+
175
+ test('Lower attribute with PascalCase key', function () {
176
+ const attribute = getAttribute(obj, lowerAttribute4);
177
+ expect(attribute).toEqual(obj[lowerAttribute3]);
178
+ });
179
+
180
+ test('Lower attribute with UPPERCASE key', function () {
181
+ const attribute = getAttribute(obj, lowerAttribute5);
182
+ expect(attribute).toEqual(obj[lowerAttribute3]);
183
+ });
184
+
185
+
186
+ test('Snake attribute with snake_case key', function () {
187
+ const attribute = getAttribute(obj, snakeAttribute1);
188
+ expect(attribute).toEqual(obj[snakeAttribute1]);
189
+ });
190
+
191
+ test('Snake attribute with camelCase key', function () {
192
+ const attribute = getAttribute(obj, snakeAttribute2);
193
+ expect(attribute).toEqual(obj[snakeAttribute1]);
194
+ });
195
+
196
+ test('Snake attribute with PascalCase key', function () {
197
+ const attribute = getAttribute(obj, snakeAttribute4);
198
+ expect(attribute).toEqual(obj[snakeAttribute1]);
199
+ });
200
+
201
+
202
+ test('Upper attribute with snake_case key', function () {
203
+ const attribute = getAttribute(obj, upperAttribute1);
204
+ expect(attribute).toEqual(obj[upperAttribute5]);
205
+ });
206
+
207
+ test('Upper attribute with camelCase key', function () {
208
+ const attribute = getAttribute(obj, upperAttribute2);
209
+ expect(attribute).toEqual(obj[upperAttribute5]);
210
+ });
211
+
212
+ test('Upper attribute with lowercase key', function () {
213
+ const attribute = getAttribute(obj, upperAttribute3);
214
+ expect(attribute).toEqual(obj[upperAttribute5]);
215
+ });
216
+
217
+ test('Upper attribute with PascalCase key', function () {
218
+ const attribute = getAttribute(obj, upperAttribute4);
219
+ expect(attribute).toEqual(obj[upperAttribute5]);
220
+ });
221
+
222
+ test('Upper attribute with UPPERCASE key', function () {
223
+ const attribute = getAttribute(obj, upperAttribute5);
224
+ expect(attribute).toEqual(obj[upperAttribute5]);
225
+ });
226
+
227
+
228
+ test('Camel attribute with snake_case key', function () {
229
+ const attribute = getAttribute(obj, camelAttribute1);
230
+ expect(attribute).toEqual(obj[camelAttribute2]);
231
+ });
232
+
233
+ test('Camel attribute with camelCase key', function () {
234
+ const attribute = getAttribute(obj, camelAttribute2);
235
+ expect(attribute).toEqual(obj[camelAttribute2]);
236
+ });
237
+
238
+ test('Camel attribute with PascalCase key', function () {
239
+ const attribute = getAttribute(obj, camelAttribute4);
240
+ expect(attribute).toEqual(obj[camelAttribute2]);
241
+ });
242
+
243
+
244
+ test('Pascal attribute with snake_case key', function () {
245
+ const attribute = getAttribute(obj, pascalAttribute1);
246
+ expect(attribute).toEqual(obj[pascalAttribute4]);
247
+ });
248
+
249
+ test('Pascal attribute with camelCase key', function () {
250
+ const attribute = getAttribute(obj, pascalAttribute2);
251
+ expect(attribute).toEqual(obj[pascalAttribute4]);
252
+ });
253
+
254
+ test('Pascal attribute with PascalCase key', function () {
255
+ const attribute = getAttribute(obj, pascalAttribute4);
256
+ expect(attribute).toEqual(obj[pascalAttribute4]);
257
+ });
258
+ });
259
+
260
+ describe('No-match Keys', function() {
261
+ const noCaseKey1 = 'customTokenS';
262
+ const noCaseKey2 = 'loadstyles';
263
+ const noCaseKey3 = 'api_KEY';
264
+
265
+ const key4 = 'apikey';
266
+ const key5 = 'APIKEY'
267
+ const key6 = 'customtokens';
268
+ const key7 = 'CUSTOMTOKENS';
269
+ const key8 = 'loadstyles';
270
+ const key9 = 'LOADSTYLES';
271
+
272
+ test('No match #1', function () {
273
+ const empty = getAttribute(obj, noCaseKey1);
274
+ expect(empty).toBeUndefined();
275
+ });
276
+
277
+ test('No match #2', function () {
278
+ const empty = getAttribute(obj, noCaseKey2);
279
+ expect(empty).toBeUndefined();
280
+ });
281
+
282
+ test('No match #3', function () {
283
+ const empty = getAttribute(obj, noCaseKey3);
284
+ expect(empty).toBeUndefined();
285
+ });
286
+
287
+ test('Snake attribute with lowercase key', function () {
288
+ const attribute = getAttribute(obj, key4);
289
+ expect(attribute).toBeUndefined();
290
+ });
291
+
292
+ test('Snake attribute with UPPERCASE key', function () {
293
+ const attribute = getAttribute(obj, key5);
294
+ expect(attribute).toBeUndefined();
295
+ });
296
+
297
+ test('Camel attribute with lowercase key', function () {
298
+ const attribute = getAttribute(obj, key6);
299
+ expect(attribute).toBeUndefined();
300
+ });
301
+
302
+ test('Camel attribute with UPPERCASE key', function () {
303
+ const attribute = getAttribute(obj, key7);
304
+ expect(attribute).toBeUndefined();
305
+ });
306
+
307
+ test('Pascal attribute with lowercase key', function () {
308
+ const attribute = getAttribute(obj, key8);
309
+ expect(attribute).toBeUndefined();
310
+ });
311
+
312
+ test('Pascal attribute with UPPERCASE key', function () {
313
+ const attribute = getAttribute(obj, key9);
314
+ expect(attribute).toBeUndefined();
315
+ });
316
+ });
@@ -0,0 +1,103 @@
1
+ const { _hasProperty } = require('../../../dist/cjs');
2
+
3
+ const obj = {
4
+ api_key: "2Wo1LiLW4uiAiJ9FU6BphNEjxTqQNc5aPhCnpkL6",
5
+ custom_tokens: { sample: Array(2) },
6
+ load_styles: false,
7
+ app_id: "D_64XzSNz",
8
+ domain: "https://postdev1.qrveyapp.com",
9
+ qrvey_id: "5LtRi43_qt",
10
+ };
11
+
12
+ const arr = [{ tag1: 'Hello', tag2: 'World' }];
13
+
14
+ describe('Testing with empty arguments', function () {
15
+ const empty1 = undefined;
16
+ const empty2 = null;
17
+ const empty3 = {};
18
+
19
+ test('No arguments', function () {
20
+ const hasProperty = _hasProperty();
21
+ expect(hasProperty).toBeFalsy();
22
+ });
23
+
24
+ test('Undefined first argument', function () {
25
+ const hasProperty = _hasProperty(empty1);
26
+ expect(hasProperty).toBeFalsy();
27
+ });
28
+
29
+ test('Null first argument with filled second argument', function () {
30
+ const hasProperty = _hasProperty(empty2, 'api_key');
31
+ expect(hasProperty).toBeFalsy();
32
+ });
33
+
34
+ test('Empty object with filled second argument', function () {
35
+ const hasProperty = _hasProperty(empty3, 'api_key');
36
+ expect(hasProperty).toBeFalsy();
37
+ });
38
+ });
39
+
40
+ describe('Testing with different argument type', function () {
41
+ const variable1 = 'Hello World';
42
+ const variable2 = 1;
43
+ const variable3 = true;
44
+ const variable4 = new Date();
45
+
46
+ test('String variable', function () {
47
+ const hasProperty = _hasProperty(variable1, 'api_key');
48
+ expect(hasProperty).toBeFalsy();
49
+ });
50
+
51
+ test('Numeric variable', function () {
52
+ const hasProperty = _hasProperty(variable2, 'api_key');
53
+ expect(hasProperty).toBeFalsy();
54
+ });
55
+
56
+ test('Boolean variable', function () {
57
+ const hasProperty = _hasProperty(variable3, 'api_key');
58
+ expect(hasProperty).toBeFalsy();
59
+ });
60
+
61
+ test('Date variable', function () {
62
+ const hasProperty = _hasProperty(variable4, 'api_key');
63
+ expect(hasProperty).toBeFalsy();
64
+ });
65
+
66
+ test('Numeric-type key', function () {
67
+ const hasProperty = _hasProperty(obj, variable2);
68
+ expect(hasProperty).toBeFalsy();
69
+ });
70
+
71
+ test('boolean-type key', function () {
72
+ const hasProperty = _hasProperty(obj, variable3);
73
+ expect(hasProperty).toBeFalsy();
74
+ });
75
+
76
+ test('Date-type key', function () {
77
+ const hasProperty = _hasProperty(obj, variable4);
78
+ expect(hasProperty).toBeFalsy();
79
+ });
80
+
81
+ test('Array-type key', function () {
82
+ const hasProperty = _hasProperty(obj, arr);
83
+ expect(hasProperty).toBeFalsy();
84
+ });
85
+ });
86
+
87
+
88
+ describe('Matching a property with the attribute', function () {
89
+ test('Object', function () {
90
+ const hasProperty = _hasProperty(obj, 'api_key');
91
+ expect(hasProperty).toBeTruthy();
92
+ });
93
+
94
+ test('Array', function () {
95
+ const hasProperty = _hasProperty(arr, '0');
96
+ expect(hasProperty).toBeTruthy();
97
+ });
98
+
99
+ test('Not matching', function () {
100
+ const hasProperty = _hasProperty(obj, 'apikey');
101
+ expect(hasProperty).toBeFalsy();
102
+ });
103
+ });
@@ -0,0 +1,105 @@
1
+ const { objectCopy } = require('../../../dist/cjs');
2
+
3
+ describe('Testing with empty arguments', function () {
4
+ const empty1 = undefined;
5
+ const empty2 = [];
6
+ const empty3 = {};
7
+
8
+ test('No arguments', function () {
9
+ const empty = objectCopy();
10
+ expect(empty).toBeUndefined();
11
+ });
12
+
13
+ test('Undefined variable', function () {
14
+ const empty = objectCopy(empty1);
15
+ expect(empty).toBeUndefined();
16
+ });
17
+
18
+ test('Empty Array variable', function () {
19
+ const empty = objectCopy(empty2);
20
+ expect(empty).toStrictEqual(empty2);
21
+ });
22
+
23
+ test('Empty Object variable', function () {
24
+ const empty = objectCopy(empty3);
25
+ expect(empty).toStrictEqual(empty3);
26
+ });
27
+ });
28
+
29
+ describe('Testing with different argument type', function () {
30
+ const variable1 = 'Hello World';
31
+ const variable2 = 1;
32
+ const variable3 = true;
33
+
34
+ test('String variable', function () {
35
+ const cDVariable1 = objectCopy(variable1);
36
+ expect(cDVariable1).toBe(variable1);
37
+ });
38
+
39
+ test('Numeric variable', function () {
40
+ const cDVariable2 = objectCopy(variable2);
41
+ expect(cDVariable2).toBe(variable2);
42
+ });
43
+
44
+ test('Boolean variable', function () {
45
+ const cDVariable3 = objectCopy(variable3);
46
+ expect(cDVariable3).toBe(variable3);
47
+ });
48
+ });
49
+
50
+
51
+ describe('Creating an new reference by object/array variables', function () {
52
+ const spanishSalutation = 'Hola';
53
+ const variable1 = ['Hello', 'World'];
54
+ const variable2 = { tag1: 'Hello', tag2: 'World' };
55
+ const variable3 = [{ tag1: 'Hello1', tag2: 'World1' }, { tag1: 'Hello2', tag2: 'World2' }];
56
+ const variable4 = new Date('2021-10-01');
57
+
58
+ const cDVariable1 = objectCopy(variable1);
59
+ const cDVariable2 = objectCopy(variable2);
60
+ const cDVariable3 = objectCopy(variable3);
61
+ const cDVariable4 = objectCopy(variable4);
62
+
63
+ test('Compare the arrays as object instances', function () {
64
+ expect(cDVariable1).not.toBe(variable1);
65
+ });
66
+
67
+ test('Compare the arrays values', function () {
68
+ expect(cDVariable1).toEqual(variable1);
69
+ });
70
+
71
+ test('Edit a cloned array value and comparing it' , function () {
72
+ cDVariable1[0] = spanishSalutation;
73
+ expect(cDVariable1).not.toEqual(variable1);
74
+ });
75
+
76
+ test('Compare the objects as object instances' , function () {
77
+ expect(cDVariable2).not.toBe(variable2);
78
+ });
79
+
80
+ test('Compare the object properties', function () {
81
+ expect(cDVariable2).toEqual(variable2);
82
+ });
83
+
84
+ test('Edit a cloned object property and comparing it' , function () {
85
+ cDVariable2.tag1 = spanishSalutation;
86
+ expect(cDVariable2).not.toEqual(variable2);
87
+ });
88
+
89
+ test('Compare the object-item arrays as object instances' , function () {
90
+ expect(cDVariable3).not.toBe(variable3);
91
+ });
92
+
93
+ test('Compare the arrays object-items', function () {
94
+ expect(cDVariable3).toEqual(variable3);
95
+ });
96
+
97
+ test('Edit a cloned object-item array property and comparing it' , function () {
98
+ cDVariable3[0].tag1 = spanishSalutation;
99
+ expect(cDVariable3).not.toEqual(variable3);
100
+ });
101
+
102
+ test('Cloning Date variable and comparing it' , function () {
103
+ expect(cDVariable4).not.toEqual(variable4);
104
+ });
105
+ });
@@ -0,0 +1,87 @@
1
+ const { capitalize } = require('../../../dist/cjs');
2
+
3
+ describe('Testing with empty arguments', function () {
4
+ const empty1 = undefined;
5
+ const empty2 = [];
6
+ const empty3 = {};
7
+ const empty4 = '';
8
+ const empty5 = null;
9
+
10
+ test('No arguments', function () {
11
+ const text = capitalize();
12
+ expect(text).toBe("");
13
+ });
14
+
15
+ test('Undefined variable', function () {
16
+ const text = capitalize(empty1);
17
+ expect(text).toBe("");
18
+ });
19
+
20
+ test('Empty Array variable', function () {
21
+ const text = capitalize(empty2);
22
+ expect(text).toBe(empty2);
23
+ });
24
+
25
+ test('Empty Object variable', function () {
26
+ const text = capitalize(empty3);
27
+ expect(text).toBe(empty3);
28
+ });
29
+
30
+ test('Empty String variable', function () {
31
+ const text = capitalize(empty4);
32
+ expect(text).toBe(empty4);
33
+ });
34
+
35
+ test('Null variable', function () {
36
+ const text = capitalize(empty5);
37
+ expect(text).toBe(empty5);
38
+ });
39
+ });
40
+
41
+ describe('Testing differente types', function () {
42
+ const variable1 = 1;
43
+ const variable2 = false;
44
+ const variable3 = new Date();
45
+ const variable4 = dig1 => dig1;
46
+
47
+ test('Numeric type', function () {
48
+ const text = capitalize(variable1);
49
+ expect(text).toBe(variable1);
50
+ });
51
+
52
+ test('Boolean type', function () {
53
+ const text = capitalize(variable2);
54
+ expect(text).toBe(variable2);
55
+ });
56
+
57
+ test('Date type', function () {
58
+ const text = capitalize(variable3);
59
+ expect(text).toBe(variable3);
60
+ });
61
+
62
+ test('Function type', function () {
63
+ const text = capitalize(variable4);
64
+ expect(text).toBe(variable4);
65
+ });
66
+ });
67
+
68
+ describe('Common scenarios', function () {
69
+ const variable1 = "hello world";
70
+ const variable2 = "hOLA MUNDO";
71
+ const variable3 = 'HELLO THERE';
72
+
73
+ test('Scenario #1', function () {
74
+ const text = capitalize(variable1);
75
+ expect(text).toBe("Hello world");
76
+ });
77
+
78
+ test('Scenario #2', function () {
79
+ const text = capitalize(variable2);
80
+ expect(text).toBe("Hola mundo");
81
+ });
82
+
83
+ test('Scenario #3', function () {
84
+ const text = capitalize(variable3);
85
+ expect(text).toBe("Hello there");
86
+ });
87
+ });