@sankhyalabs/core 6.0.1 → 6.1.0-dev.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.
Files changed (71) hide show
  1. package/.docs/classes/Change.md +11 -11
  2. package/.docs/classes/DataUnit.md +230 -122
  3. package/.docs/classes/FieldComparator.md +6 -2
  4. package/.docs/classes/KeyboardManager.md +99 -9
  5. package/.docs/classes/LockManager.md +4 -4
  6. package/.docs/classes/ObjectUtils.md +50 -2
  7. package/.docs/classes/SelectionInfo.md +12 -12
  8. package/.docs/classes/StringUtils.md +10 -10
  9. package/.docs/enumerations/Action.md +41 -31
  10. package/.docs/enumerations/ChangeOperation.md +4 -4
  11. package/.docs/enumerations/SelectionMode.md +2 -2
  12. package/.docs/enumerations/UserInterface.md +15 -5
  13. package/.docs/interfaces/DUActionInterceptor.md +1 -1
  14. package/.docs/interfaces/PageRequest.md +3 -3
  15. package/.docs/interfaces/QuickFilter.md +3 -3
  16. package/.docs/interfaces/Record.md +4 -4
  17. package/.docs/interfaces/SavedRecord.md +5 -5
  18. package/.docs/interfaces/WaitingChange.md +3 -3
  19. package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
  20. package/dist/dataunit/DataUnit.d.ts +19 -0
  21. package/dist/dataunit/DataUnit.js +43 -3
  22. package/dist/dataunit/DataUnit.js.map +1 -1
  23. package/dist/dataunit/formatting/PrettyFormatter.js +8 -3
  24. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
  25. package/dist/dataunit/metadata/DataType.d.ts +1 -1
  26. package/dist/dataunit/metadata/DataType.js +7 -4
  27. package/dist/dataunit/metadata/DataType.js.map +1 -1
  28. package/dist/dataunit/metadata/UnitMetadata.d.ts +1 -0
  29. package/dist/dataunit/metadata/UnitMetadata.js +1 -0
  30. package/dist/dataunit/metadata/UnitMetadata.js.map +1 -1
  31. package/dist/dataunit/sorting/FieldComparator.d.ts +2 -2
  32. package/dist/dataunit/sorting/FieldComparator.js +4 -4
  33. package/dist/dataunit/sorting/FieldComparator.js.map +1 -1
  34. package/dist/dataunit/state/action/DataUnitAction.d.ts +1 -0
  35. package/dist/dataunit/state/action/DataUnitAction.js +1 -0
  36. package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
  37. package/dist/utils/KeyboardManager/index.d.ts +9 -0
  38. package/dist/utils/KeyboardManager/index.js +45 -1
  39. package/dist/utils/KeyboardManager/index.js.map +1 -1
  40. package/dist/utils/KeyboardManager/interface.d.ts +1 -0
  41. package/dist/utils/LockManager.js.map +1 -1
  42. package/dist/utils/ObjectUtils.d.ts +14 -0
  43. package/dist/utils/ObjectUtils.js +20 -0
  44. package/dist/utils/ObjectUtils.js.map +1 -1
  45. package/dist/utils/SortingUtils.js +9 -1
  46. package/dist/utils/SortingUtils.js.map +1 -1
  47. package/dist/utils/StringUtils.js +12 -6
  48. package/dist/utils/StringUtils.js.map +1 -1
  49. package/package.json +1 -1
  50. package/reports/test-report.xml +669 -124
  51. package/src/dataunit/DataUnit.ts +51 -3
  52. package/src/dataunit/formatting/PrettyFormatter.ts +8 -5
  53. package/src/dataunit/metadata/DataType.ts +8 -4
  54. package/src/dataunit/metadata/UnitMetadata.ts +1 -0
  55. package/src/dataunit/sorting/FieldComparator.ts +4 -4
  56. package/src/dataunit/state/action/DataUnitAction.ts +2 -0
  57. package/src/utils/KeyboardManager/index.ts +57 -0
  58. package/src/utils/KeyboardManager/interface.ts +1 -0
  59. package/src/utils/LockManager.ts +0 -1
  60. package/src/utils/ObjectUtils.ts +21 -0
  61. package/src/utils/SortingUtils.ts +10 -1
  62. package/src/utils/StringUtils.ts +10 -6
  63. package/test/dataunit/formatting/PrettyFormatter.spec.ts +1 -1
  64. package/test/testCases/NumberUtilsTestCases.ts +190 -0
  65. package/test/testCases/StringUtilsTestCases.ts +435 -0
  66. package/test/testCases/TimeFormatterTestUtils.ts +43 -0
  67. package/test/util/NumberUtils.spec.ts +72 -150
  68. package/test/util/ObjectUtils.spec.ts +572 -0
  69. package/test/util/StringUtils.spec.ts +260 -36
  70. package/test/util/TimeFormatter.spec.ts +65 -18
  71. package/src/utils/test/objectUtils.spec.ts +0 -109
@@ -0,0 +1,572 @@
1
+ import ObjectUtils from '../../src/utils/ObjectUtils';
2
+
3
+ describe('ObjectUtils', () => {
4
+
5
+ describe('getProp', () => {
6
+ it('should get an object value based on its path', async () => {
7
+ const value = ObjectUtils.getProp(defaultObjectMock, 'food.fruits.banana');
8
+ expect(value).toBe(2);
9
+ });
10
+
11
+ it('should get an object value based on its path', async () => {
12
+ const value = ObjectUtils.getProp(defaultObjectMock, 'food');
13
+ expect(JSON.stringify(value)).toBe(JSON.stringify(defaultObjectMock.food));
14
+ });
15
+
16
+ it('should return undefined if the path doesn\'t exist in the object', async () => {
17
+ const value = ObjectUtils.getProp(defaultObjectMock, 'vegetables');
18
+ expect(value).toBe(undefined);
19
+ });
20
+ });
21
+
22
+
23
+ describe('hasEquivalentValues', () => {
24
+ it('should return true if both objects have the same property value', () => {
25
+ const obj1 = { value: 10 };
26
+ const obj2 = { value: 10 };
27
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(true);
28
+ });
29
+
30
+ it('should return false if both objects have different property values', () => {
31
+ const obj1 = { value: 10 };
32
+ const obj2 = { value: 20 };
33
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(false);
34
+ });
35
+
36
+ it('should return true if both objects are equivalent with custom property to compare', () => {
37
+ const obj1 = { customProp: 'hello' };
38
+ const obj2 = { customProp: 'hello' };
39
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2, 'customProp')).toBe(true);
40
+ });
41
+
42
+ it('should return false if both objects are not equivalent with custom property to compare', () => {
43
+ const obj1 = { customProp: 'hello' };
44
+ const obj2 = { customProp: 'world' };
45
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2, 'customProp')).toBe(false);
46
+ });
47
+
48
+ it('should return false if one object does not have the property', () => {
49
+ const obj1 = { value: 10 };
50
+ const obj2 = { anotherProp: 10 };
51
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(false);
52
+ });
53
+
54
+ it('should return true if comparing primitive values directly', () => {
55
+ const obj1 = 5;
56
+ const obj2 = 5;
57
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(true);
58
+ });
59
+
60
+ it('should return false if comparing different primitive values', () => {
61
+ const obj1 = 5;
62
+ const obj2 = 10;
63
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(false);
64
+ });
65
+
66
+ it('should return true when comparing object with a null value', () => {
67
+ const obj1 = null;
68
+ const obj2 = null;
69
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(true);
70
+ });
71
+
72
+ it('should return false when comparing object with null and non-null value', () => {
73
+ const obj1 = null;
74
+ const obj2 = { value: 5 };
75
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(false);
76
+ });
77
+
78
+ it('should return true when comparing non-object values that are equal', () => {
79
+ const obj1 = 'same';
80
+ const obj2 = 'same';
81
+ expect(ObjectUtils.hasEquivalentProps(obj1, obj2)).toBe(true);
82
+ });
83
+
84
+ });
85
+
86
+
87
+ describe('copy', () => {
88
+ it('should copy a simple object', () => {
89
+ const original = { nome: 'Sankhya', cidade: 'Uberlandia' };
90
+ const copy = ObjectUtils.copy(original);
91
+
92
+ expect(copy).toEqual(original);
93
+ expect(copy).not.toBe(original);
94
+ });
95
+
96
+ it('should copy an array of objects', () => {
97
+ const original = [{ nome: 'Sankhya' }, { cidade: 'Uberlandia' }];
98
+ const copy: any = ObjectUtils.copy(original);
99
+
100
+ expect(copy).toEqual(original);
101
+ expect(copy).not.toBe(original);
102
+ expect(copy[0]).not.toBe(original[0]);
103
+ });
104
+
105
+ it('should copy an object with nested properties', () => {
106
+ const original = { pessoa: { nome: 'Sankhya', cidade: 'Uberlandia' } };
107
+ const copy: any = ObjectUtils.copy(original);
108
+
109
+ expect(copy).toEqual(original);
110
+ expect(copy).not.toBe(original);
111
+ expect(copy.pessoa).not.toBe(original.pessoa);
112
+ });
113
+
114
+ it('should copy an object with null or undefined values', () => {
115
+ const original = { nome: null, cidade: undefined, idade: 30 };
116
+ const copy = ObjectUtils.copy(original);
117
+
118
+ expect(copy).toEqual(original);
119
+ expect(copy).not.toBe(original);
120
+ });
121
+
122
+ it('should copy an empty object', () => {
123
+ const original = {};
124
+ const copy = ObjectUtils.copy(original);
125
+
126
+ expect(copy).toEqual(original);
127
+ expect(copy).not.toBe(original);
128
+ });
129
+
130
+ it('should copy an object with mixed types of values', () => {
131
+ const original = {
132
+ numero: 123,
133
+ texto: 'Test',
134
+ array: [1, 2, 3],
135
+ objeto: { chave: 'valor' },
136
+ };
137
+ const copy: any = ObjectUtils.copy(original);
138
+
139
+ expect(copy).toEqual(original);
140
+ expect(copy).not.toBe(original);
141
+ expect(copy.array).not.toBe(original.array);
142
+ expect(copy.objeto).not.toBe(original.objeto);
143
+ });
144
+ });
145
+
146
+
147
+ describe('objectToString', () => {
148
+ it('should convert a simple object to JSON string', () => {
149
+ const original = { nome: 'Sankhya', cidade: 'Uberlandia' };
150
+ const jsonString = ObjectUtils.objectToString(original);
151
+
152
+ expect(jsonString).toBe('{"nome":"Sankhya","cidade":"Uberlandia"}');
153
+ });
154
+
155
+ it('should convert an array of objects to JSON string', () => {
156
+ const original = [{ nome: 'Sankhya' }, { cidade: 'Uberlandia' }];
157
+ const jsonString = ObjectUtils.objectToString(original);
158
+
159
+ expect(jsonString).toBe('[{"nome":"Sankhya"},{"cidade":"Uberlandia"}]');
160
+ });
161
+
162
+ it('should convert a nested object to JSON string', () => {
163
+ const original = { pessoa: { nome: 'Sankhya', cidade: 'Uberlandia' } };
164
+ const jsonString = ObjectUtils.objectToString(original);
165
+
166
+ expect(jsonString).toBe('{"pessoa":{"nome":"Sankhya","cidade":"Uberlandia"}}');
167
+ });
168
+
169
+ it('should convert an object with null and undefined values to JSON string', () => {
170
+ const original = { nome: null, cidade: undefined, idade: 30 };
171
+ const jsonString = ObjectUtils.objectToString(original);
172
+
173
+ expect(jsonString).toBe('{"nome":null,"idade":30}');
174
+ });
175
+
176
+ it('should convert an empty object to JSON string', () => {
177
+ const original = {};
178
+ const jsonString = ObjectUtils.objectToString(original);
179
+
180
+ expect(jsonString).toBe('{}');
181
+ });
182
+
183
+ it('should convert an object with mixed types of values to JSON string', () => {
184
+ const original = {
185
+ numero: 123,
186
+ texto: 'Test',
187
+ array: [1, 2, 3],
188
+ objeto: { chave: 'valor' },
189
+ };
190
+ const jsonString = ObjectUtils.objectToString(original);
191
+
192
+ expect(jsonString).toBe('{"numero":123,"texto":"Test","array":[1,2,3],"objeto":{"chave":"valor"}}');
193
+ });
194
+ });
195
+
196
+
197
+ describe('stringToObject', () => {
198
+
199
+ it('should convert a simple JSON string to an object', () => {
200
+ const jsonString = '{"nome":"Sankhya","cidade":"Uberlandia"}';
201
+ const parsedObject = ObjectUtils.stringToObject(jsonString);
202
+
203
+ expect(parsedObject).toEqual({ nome: 'Sankhya', cidade: 'Uberlandia' });
204
+ });
205
+
206
+ it('should convert a JSON string representing an array of objects to an array of objects', () => {
207
+ const jsonString = '[{"nome":"Sankhya"},{"cidade":"Uberlandia"}]';
208
+ const parsedObject = ObjectUtils.stringToObject(jsonString);
209
+
210
+ expect(parsedObject).toEqual([{ nome: 'Sankhya' }, { cidade: 'Uberlandia' }]);
211
+ });
212
+
213
+ it('should convert a JSON string representing a nested object to an object', () => {
214
+ const jsonString = '{"pessoa":{"nome":"Sankhya","cidade":"Uberlandia"}}';
215
+ const parsedObject = ObjectUtils.stringToObject(jsonString);
216
+
217
+ expect(parsedObject).toEqual({ pessoa: { nome: 'Sankhya', cidade: 'Uberlandia' } });
218
+ });
219
+
220
+ it('should convert a JSON string with null and undefined values to an object', () => {
221
+ const jsonString = '{"nome":null,"cidade":null,"idade":30}';
222
+ const parsedObject = ObjectUtils.stringToObject(jsonString);
223
+
224
+ expect(parsedObject).toEqual({ nome: null, cidade: null, idade: 30 });
225
+ });
226
+
227
+ it('should convert an empty JSON string to an empty object', () => {
228
+ const jsonString = '{}';
229
+ const parsedObject = ObjectUtils.stringToObject(jsonString);
230
+
231
+ expect(parsedObject).toEqual({});
232
+ });
233
+
234
+ it('should throw an error for an invalid JSON string', () => {
235
+ const invalidJsonString = '{"nome": "Sankhya", "cidade": "Uberlandia"';
236
+
237
+ expect(() => {
238
+ ObjectUtils.stringToObject(invalidJsonString);
239
+ }).toThrow(SyntaxError);
240
+ });
241
+ });
242
+
243
+
244
+ describe('sortByProperty', () => {
245
+
246
+ it('should sort an object by a numerical property', () => {
247
+ const original = {
248
+ obj1: { id: 3, nome: 'Sankhya' },
249
+ obj2: { id: 1, nome: 'Uberlandia' },
250
+ obj3: { id: 2, nome: 'Tech' },
251
+ };
252
+ const sorted = ObjectUtils.sortByProperty(original, 'id');
253
+
254
+ const expected = {
255
+ obj2: { id: 1, nome: 'Uberlandia' },
256
+ obj3: { id: 2, nome: 'Tech' },
257
+ obj1: { id: 3, nome: 'Sankhya' },
258
+ };
259
+
260
+ expect(sorted).toEqual(expected);
261
+ });
262
+
263
+ it('should sort an object by a string property', () => {
264
+ const original = {
265
+ obj1: { nome: 'Sankhya' },
266
+ obj2: { nome: 'Uberlandia' },
267
+ obj3: { nome: 'Tech' },
268
+ };
269
+ const sorted = ObjectUtils.sortByProperty(original, 'nome');
270
+
271
+ const expected = {
272
+ obj3: { nome: 'Tech' },
273
+ obj2: { nome: 'Uberlandia' },
274
+ obj1: { nome: 'Sankhya' },
275
+ };
276
+
277
+ expect(sorted).toEqual(expected);
278
+ });
279
+
280
+ it('should handle null values correctly when sorting', () => {
281
+ const original = {
282
+ obj1: { id: 3, nome: 'Sankhya' },
283
+ obj2: { id: null, nome: 'Uberlandia' },
284
+ obj3: { id: 2, nome: 'Tech' },
285
+ };
286
+ const sorted = ObjectUtils.sortByProperty(original, 'id');
287
+
288
+ const expected = {
289
+ obj2: { id: null, nome: 'Uberlandia' },
290
+ obj3: { id: 2, nome: 'Tech' },
291
+ obj1: { id: 3, nome: 'Sankhya' },
292
+ };
293
+
294
+ expect(sorted).toEqual(expected);
295
+ });
296
+
297
+ });
298
+
299
+
300
+ describe('removeEmptyValues', () => {
301
+ it('should remove properties with null or undefined values in a simple object', () => {
302
+ const original = {
303
+ nome: 'Sankhya',
304
+ cidade: null,
305
+ idade: undefined,
306
+ pais: 'Brasil',
307
+ };
308
+ const result = ObjectUtils.removeEmptyValues(original);
309
+
310
+ const expected = { nome: 'Sankhya', pais: 'Brasil' };
311
+ expect(result).toEqual(expected);
312
+ });
313
+
314
+ it('should remove properties with null or undefined values in a nested object', () => {
315
+ const original = {
316
+ pessoa: {
317
+ nome: 'Sankhya',
318
+ idade: null,
319
+ endereco: {
320
+ rua: 'Av. Brasil',
321
+ cidade: undefined,
322
+ },
323
+ },
324
+ empresa: {
325
+ nome: 'Tech',
326
+ sede: null,
327
+ },
328
+ };
329
+ const result = ObjectUtils.removeEmptyValues(original);
330
+
331
+ const expected = {
332
+ pessoa: {
333
+ nome: 'Sankhya',
334
+ endereco: { rua: 'Av. Brasil' },
335
+ },
336
+ empresa: { nome: 'Tech' },
337
+ };
338
+
339
+ expect(result).toEqual(expected);
340
+ });
341
+
342
+ it('should remove empty values in an array inside an object', () => {
343
+ const original = {
344
+ pessoas: [
345
+ { nome: 'Sankhya', idade: null },
346
+ { nome: 'Uberlandia', idade: undefined },
347
+ { nome: 'Tech', idade: 30 },
348
+ ],
349
+ };
350
+ const result = ObjectUtils.removeEmptyValues(original);
351
+
352
+ const expected = {
353
+ pessoas: {
354
+ 0: { nome: 'Sankhya' },
355
+ 1: { nome: 'Uberlandia' },
356
+ 2: { nome: 'Tech', idade: 30 },
357
+ },
358
+ };
359
+
360
+ expect(result).toEqual(expected);
361
+ });
362
+
363
+ it('should not modify an object with no null or undefined values', () => {
364
+ const original = {
365
+ nome: 'Sankhya',
366
+ cidade: 'Uberlandia',
367
+ idade: 30,
368
+ };
369
+ const result = ObjectUtils.removeEmptyValues(original);
370
+
371
+ expect(result).toEqual(original);
372
+ });
373
+
374
+ it('should return an empty object if all properties are removed', () => {
375
+ const original = {
376
+ nome: null,
377
+ cidade: undefined,
378
+ };
379
+ const result = ObjectUtils.removeEmptyValues(original);
380
+
381
+ const expected = {};
382
+ expect(result).toEqual(expected);
383
+ });
384
+ });
385
+
386
+
387
+ describe('equals', () => {
388
+
389
+ it('should return true for identical objects', () => {
390
+ const obj1 = { nome: 'Sankhya', idade: 30 };
391
+ const obj2 = { nome: 'Sankhya', idade: 30 };
392
+
393
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(true);
394
+ });
395
+
396
+ it('should return false for different objects', () => {
397
+ const obj1 = { nome: 'Sankhya', idade: 30 };
398
+ const obj2 = { nome: 'Uberlandia', idade: 25 };
399
+
400
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(false);
401
+ });
402
+
403
+ it('should return true for identical nested objects', () => {
404
+ const obj1 = { pessoa: { nome: 'Sankhya', idade: 30 }, cidade: 'Uberlandia' };
405
+ const obj2 = { pessoa: { nome: 'Sankhya', idade: 30 }, cidade: 'Uberlandia' };
406
+
407
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(true);
408
+ });
409
+
410
+ it('should return false for different nested objects', () => {
411
+ const obj1 = { pessoa: { nome: 'Sankhya', idade: 30 }, cidade: 'Uberlandia' };
412
+ const obj2 = { pessoa: { nome: 'Tech', idade: 25 }, cidade: 'Uberlandia' };
413
+
414
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(false);
415
+ });
416
+
417
+ it('should return false for objects with different types of properties', () => {
418
+ const obj1 = { nome: 'Sankhya', ativo: true, idade: 30 };
419
+ const obj2 = { nome: 'Sankhya', ativo: 'true', idade: 30 };
420
+
421
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(false);
422
+ });
423
+
424
+ it('should return true for identical arrays', () => {
425
+ const arr1 = [1, 2, 3];
426
+ const arr2 = [1, 2, 3];
427
+
428
+ expect(ObjectUtils.equals(arr1, arr2)).toBe(true);
429
+ });
430
+
431
+ it('should return false for different arrays', () => {
432
+ const arr1 = [1, 2, 3];
433
+ const arr2 = [3, 2, 1];
434
+
435
+ expect(ObjectUtils.equals(arr1, arr2)).toBe(false);
436
+ });
437
+
438
+ it('should return true for empty objects', () => {
439
+ const obj1 = {};
440
+ const obj2 = {};
441
+
442
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(true);
443
+ });
444
+
445
+ it('should return false when comparing different types (object vs array)', () => {
446
+ const obj1 = { nome: 'Sankhya' };
447
+ const arr2 = ['Sankhya'];
448
+
449
+ expect(ObjectUtils.equals(obj1, arr2)).toBe(false);
450
+ });
451
+
452
+ it('should return true for objects with null and undefined treated as different', () => {
453
+ const obj1 = { nome: null };
454
+ const obj2 = { nome: undefined };
455
+
456
+ expect(ObjectUtils.equals(obj1, obj2)).toBe(false);
457
+ });
458
+ });
459
+
460
+
461
+ describe('isEmptySafetyCheck', () => {
462
+ it('should return true for an empty object', () => {
463
+ const obj = {};
464
+ expect(ObjectUtils.isEmptySafetyCheck(obj)).toBe(true);
465
+ });
466
+
467
+ it('should return false for an object with properties', () => {
468
+ const obj = { nome: 'Sankhya' };
469
+ expect(ObjectUtils.isEmptySafetyCheck(obj)).toBe(false);
470
+ });
471
+
472
+ it('should return false for an object with nested properties', () => {
473
+ const obj = { pessoa: { nome: 'Sankhya' } };
474
+ expect(ObjectUtils.isEmptySafetyCheck(obj)).toBe(false);
475
+ });
476
+
477
+ it('should return false for an empty array', () => {
478
+ const arr: any[] = [];
479
+ expect(ObjectUtils.isEmptySafetyCheck(arr)).toBe(false);
480
+ });
481
+
482
+ it('should return false for an object with null or undefined properties', () => {
483
+ const obj = { nome: null, idade: undefined };
484
+ expect(ObjectUtils.isEmptySafetyCheck(obj)).toBe(false);
485
+ });
486
+
487
+ it('should return false for a non-empty array object', () => {
488
+ const obj = [1, 2, 3];
489
+ expect(ObjectUtils.isEmptySafetyCheck(obj)).toBe(false);
490
+ });
491
+
492
+ it('should handle null gracefully and return true', () => {
493
+ const obj = null;
494
+ expect(ObjectUtils.isEmptySafetyCheck(obj as any)).toBe(true);
495
+ });
496
+
497
+ it('should handle undefined gracefully and return true', () => {
498
+ const obj = undefined;
499
+ expect(ObjectUtils.isEmptySafetyCheck(obj as any)).toBe(true);
500
+ });
501
+
502
+ it('should return false for primitive values (numbers, strings)', () => {
503
+ expect(ObjectUtils.isEmptySafetyCheck('' as any)).toBe(false);
504
+ expect(ObjectUtils.isEmptySafetyCheck(0 as any)).toBe(false);
505
+ expect(ObjectUtils.isEmptySafetyCheck(42 as any)).toBe(false);
506
+ });
507
+
508
+ it('should return false for functions', () => {
509
+ const func = () => {
510
+ };
511
+ expect(ObjectUtils.isEmptySafetyCheck(func as any)).toBe(false);
512
+ });
513
+ });
514
+
515
+
516
+ describe('isNotEmptySafetyCheck', () => {
517
+ it('should return false for an empty object', () => {
518
+ const obj = {};
519
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj)).toBe(false);
520
+ });
521
+
522
+ it('should return true for an object with properties', () => {
523
+ const obj = { nome: 'Sankhya' };
524
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj)).toBe(true);
525
+ });
526
+
527
+ it('should return true for an object with nested properties', () => {
528
+ const obj = { pessoa: { nome: 'Sankhya' } };
529
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj)).toBe(true);
530
+ });
531
+
532
+ it('should return true for an empty array', () => {
533
+ const arr: any[] = [];
534
+ expect(ObjectUtils.isNotEmptySafetyCheck(arr)).toBe(true);
535
+ });
536
+
537
+ it('should return true for an object with null or undefined properties', () => {
538
+ const obj = { nome: null, idade: undefined };
539
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj)).toBe(true);
540
+ });
541
+
542
+ it('should return true for a non-empty array object', () => {
543
+ const obj = [1, 2, 3];
544
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj)).toBe(true);
545
+ });
546
+
547
+ it('should handle null gracefully and return false', () => {
548
+ const obj = null;
549
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj as any)).toBe(false);
550
+ });
551
+
552
+ it('should handle undefined gracefully and return false', () => {
553
+ const obj = undefined;
554
+ expect(ObjectUtils.isNotEmptySafetyCheck(obj as any)).toBe(false);
555
+ });
556
+
557
+ it('should return false for primitive values (numbers, strings)', () => {
558
+ expect(ObjectUtils.isNotEmptySafetyCheck('' as any)).toBe(true);
559
+ expect(ObjectUtils.isNotEmptySafetyCheck(0 as any)).toBe(true);
560
+ expect(ObjectUtils.isNotEmptySafetyCheck(42 as any)).toBe(true);
561
+ });
562
+
563
+ it('should return true for functions', () => {
564
+ const func = () => {
565
+ };
566
+ expect(ObjectUtils.isNotEmptySafetyCheck(func as any)).toBe(true);
567
+ });
568
+ });
569
+
570
+ });
571
+
572
+ const defaultObjectMock = { food: { fruits: { apple: 1, banana: 2 } } };