@sankhyalabs/core 5.20.0-dev.8 → 5.20.0-dev.80

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 (208) hide show
  1. package/.docs/classes/Base64Utils.md +39 -0
  2. package/.docs/classes/Change.md +11 -11
  3. package/.docs/classes/ColumnFilterManager.md +145 -0
  4. package/.docs/classes/DataUnit.md +429 -139
  5. package/.docs/classes/DataUnitInMemoryLoader.md +303 -0
  6. package/.docs/classes/DataUnitLoaderUtils.md +151 -0
  7. package/.docs/classes/DateUtils.md +8 -8
  8. package/.docs/classes/FieldComparator.md +2 -2
  9. package/.docs/classes/IDBRepository.md +22 -0
  10. package/.docs/classes/KeyboardManager.md +99 -9
  11. package/.docs/classes/LockManager.md +249 -0
  12. package/.docs/classes/MaskFormatter.md +66 -14
  13. package/.docs/classes/ObjectUtils.md +189 -0
  14. package/.docs/classes/OverflowWatcher.md +533 -0
  15. package/.docs/classes/SelectionInfo.md +25 -11
  16. package/.docs/classes/ServiceCanceledException.md +193 -0
  17. package/.docs/classes/ServiceUtils.md +67 -0
  18. package/.docs/classes/SilentException.md +193 -0
  19. package/.docs/classes/StringUtils.md +33 -9
  20. package/.docs/classes/UserAgentUtils.md +15 -1
  21. package/.docs/enumerations/Action.md +41 -21
  22. package/.docs/enumerations/ChangeOperation.md +4 -4
  23. package/.docs/enumerations/LockManagerOperation.md +33 -0
  24. package/.docs/enumerations/OverflowDirection.md +29 -0
  25. package/.docs/enumerations/RECORD_DATE_FORMAT.md +27 -0
  26. package/.docs/enumerations/SelectionMode.md +2 -2
  27. package/.docs/enumerations/StorageType.md +37 -0
  28. package/.docs/enumerations/UserInterface.md +15 -5
  29. package/.docs/globals.md +25 -0
  30. package/.docs/interfaces/DUActionInterceptor.md +1 -1
  31. package/.docs/interfaces/DataUnitInMemoryLoaderConfig.md +37 -0
  32. package/.docs/interfaces/IRepository.md +18 -0
  33. package/.docs/interfaces/LoadDataRequest.md +1 -1
  34. package/.docs/interfaces/OverFlowWatcherParams.md +67 -0
  35. package/.docs/interfaces/PageRequest.md +3 -3
  36. package/.docs/interfaces/PaginationInfo.md +25 -0
  37. package/.docs/interfaces/PaginationInfoBuilderParams.md +37 -0
  38. package/.docs/interfaces/QuickFilter.md +3 -3
  39. package/.docs/interfaces/Record.md +4 -4
  40. package/.docs/interfaces/SavedRecord.md +5 -5
  41. package/.docs/interfaces/WaitingChange.md +3 -3
  42. package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +1 -1
  43. package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +1 -1
  44. package/.docs/type-aliases/DataUnitEventOptions.md +17 -0
  45. package/.docs/type-aliases/OnOverflowCallBack.md +25 -0
  46. package/.docs/variables/OVERFLOWED_CLASS_NAME.md +13 -0
  47. package/.releaserc +1 -0
  48. package/bun.lockb +0 -0
  49. package/dist/dataunit/DataUnit.d.ts +92 -13
  50. package/dist/dataunit/DataUnit.js +227 -71
  51. package/dist/dataunit/DataUnit.js.map +1 -1
  52. package/dist/dataunit/DataUnitHelper.js +6 -5
  53. package/dist/dataunit/DataUnitHelper.js.map +1 -1
  54. package/dist/dataunit/formatting/PrettyFormatter.js +17 -6
  55. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
  56. package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.d.ts +9 -0
  57. package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.js +6 -0
  58. package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.js.map +1 -0
  59. package/dist/dataunit/loader/dataUnitInMemoryLoader.d.ts +25 -0
  60. package/dist/dataunit/loader/dataUnitInMemoryLoader.js +131 -0
  61. package/dist/dataunit/loader/dataUnitInMemoryLoader.js.map +1 -0
  62. package/dist/dataunit/loader/utils/dataUnitLoaderUtils.d.ts +20 -0
  63. package/dist/dataunit/loader/utils/dataUnitLoaderUtils.js +62 -0
  64. package/dist/dataunit/loader/utils/dataUnitLoaderUtils.js.map +1 -0
  65. package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
  66. package/dist/dataunit/loading/PaginationInfo.d.ts +8 -0
  67. package/dist/dataunit/metadata/DataType.js +7 -1
  68. package/dist/dataunit/metadata/DataType.js.map +1 -1
  69. package/dist/dataunit/metadata/UnitMetadata.d.ts +1 -0
  70. package/dist/dataunit/metadata/UnitMetadata.js +1 -0
  71. package/dist/dataunit/metadata/UnitMetadata.js.map +1 -1
  72. package/dist/dataunit/sorting/FieldComparator.d.ts +2 -2
  73. package/dist/dataunit/sorting/FieldComparator.js +4 -9
  74. package/dist/dataunit/sorting/FieldComparator.js.map +1 -1
  75. package/dist/dataunit/state/action/DataUnitAction.d.ts +2 -0
  76. package/dist/dataunit/state/action/DataUnitAction.js +2 -0
  77. package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
  78. package/dist/dataunit/state/slice/LoadingControlSlice.js +16 -0
  79. package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -1
  80. package/dist/dataunit/state/slice/RecordsSlice.js +1 -1
  81. package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -1
  82. package/dist/dataunit/state/slice/SelectionSlice.js +4 -4
  83. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
  84. package/dist/exceptions/ServiceCanceledException.d.ts +14 -0
  85. package/dist/exceptions/ServiceCanceledException.js +13 -0
  86. package/dist/exceptions/ServiceCanceledException.js.map +1 -0
  87. package/dist/exceptions/SilentException.d.ts +14 -0
  88. package/dist/exceptions/SilentException.js +13 -0
  89. package/dist/exceptions/SilentException.js.map +1 -0
  90. package/dist/index.d.ts +13 -2
  91. package/dist/index.js +12 -1
  92. package/dist/index.js.map +1 -1
  93. package/dist/repository/IRepository.d.ts +6 -0
  94. package/dist/repository/indexeddb/IDBRepository.d.ts +1 -0
  95. package/dist/repository/indexeddb/IDBRepository.js +3 -0
  96. package/dist/repository/indexeddb/IDBRepository.js.map +1 -1
  97. package/dist/utils/Base64Utils.d.ts +7 -0
  98. package/dist/utils/Base64Utils.js +13 -0
  99. package/dist/utils/Base64Utils.js.map +1 -0
  100. package/dist/utils/CacheManager/index.d.ts +52 -0
  101. package/dist/utils/CacheManager/index.js +101 -0
  102. package/dist/utils/CacheManager/index.js.map +1 -0
  103. package/dist/utils/CacheManager/interfaces/index.d.ts +5 -0
  104. package/dist/utils/CacheManager/interfaces/index.js +7 -0
  105. package/dist/utils/CacheManager/interfaces/index.js.map +1 -0
  106. package/dist/utils/ColumnFilterManager.d.ts +19 -0
  107. package/dist/utils/ColumnFilterManager.js +73 -0
  108. package/dist/utils/ColumnFilterManager.js.map +1 -0
  109. package/dist/utils/DateUtils.js +3 -0
  110. package/dist/utils/DateUtils.js.map +1 -1
  111. package/dist/utils/ElementUtils.d.ts +2 -0
  112. package/dist/utils/ElementUtils.js +9 -0
  113. package/dist/utils/ElementUtils.js.map +1 -0
  114. package/dist/utils/KeyboardManager/index.d.ts +9 -0
  115. package/dist/utils/KeyboardManager/index.js +45 -1
  116. package/dist/utils/KeyboardManager/index.js.map +1 -1
  117. package/dist/utils/KeyboardManager/interface.d.ts +1 -0
  118. package/dist/utils/LockManager.d.ts +58 -0
  119. package/dist/utils/LockManager.js +188 -0
  120. package/dist/utils/LockManager.js.map +1 -0
  121. package/dist/utils/MaskFormatter.d.ts +16 -1
  122. package/dist/utils/MaskFormatter.js +82 -2
  123. package/dist/utils/MaskFormatter.js.map +1 -1
  124. package/dist/utils/ObjectUtils.d.ts +52 -0
  125. package/dist/utils/ObjectUtils.js +71 -0
  126. package/dist/utils/ObjectUtils.js.map +1 -1
  127. package/dist/utils/OnboardingUtils.js +1 -1
  128. package/dist/utils/OnboardingUtils.js.map +1 -1
  129. package/dist/utils/OverflowWatcher/index.d.ts +59 -0
  130. package/dist/utils/OverflowWatcher/index.js +188 -0
  131. package/dist/utils/OverflowWatcher/index.js.map +1 -0
  132. package/dist/utils/OverflowWatcher/types/overflow-callback.d.ts +6 -0
  133. package/dist/utils/OverflowWatcher/types/overflow-callback.js +2 -0
  134. package/dist/utils/OverflowWatcher/types/overflow-callback.js.map +1 -0
  135. package/dist/utils/OverflowWatcher/types/overflow-direction.d.ts +7 -0
  136. package/dist/utils/OverflowWatcher/types/overflow-direction.js +9 -0
  137. package/dist/utils/OverflowWatcher/types/overflow-direction.js.map +1 -0
  138. package/dist/utils/ServiceUtils.d.ts +24 -0
  139. package/dist/utils/ServiceUtils.js +40 -0
  140. package/dist/utils/ServiceUtils.js.map +1 -0
  141. package/dist/utils/SortingUtils.d.ts +9 -0
  142. package/dist/utils/SortingUtils.js +24 -0
  143. package/dist/utils/SortingUtils.js.map +1 -0
  144. package/dist/utils/StringUtils.d.ts +6 -0
  145. package/dist/utils/StringUtils.js +23 -6
  146. package/dist/utils/StringUtils.js.map +1 -1
  147. package/dist/utils/UserAgentUtils/index.d.ts +1 -0
  148. package/dist/utils/UserAgentUtils/index.js +5 -0
  149. package/dist/utils/UserAgentUtils/index.js.map +1 -1
  150. package/jest.config.ts +2 -0
  151. package/package.json +2 -1
  152. package/reports/test-report.xml +760 -0
  153. package/setupTests.js +7 -0
  154. package/sonar-project.properties +6 -3
  155. package/src/dataunit/DataUnit.ts +278 -86
  156. package/src/dataunit/DataUnitHelper.ts +6 -5
  157. package/src/dataunit/formatting/PrettyFormatter.ts +19 -6
  158. package/src/dataunit/loader/DataUnitInMemoryLoaderConfig.ts +10 -0
  159. package/src/dataunit/loader/dataUnitInMemoryLoader.ts +176 -0
  160. package/src/dataunit/loader/utils/dataUnitLoaderUtils.ts +86 -0
  161. package/src/dataunit/loading/LoadDataRequest.ts +1 -1
  162. package/src/dataunit/loading/PaginationInfo.ts +10 -0
  163. package/src/dataunit/metadata/DataType.ts +8 -1
  164. package/src/dataunit/metadata/UnitMetadata.ts +1 -0
  165. package/src/dataunit/sorting/FieldComparator.ts +18 -32
  166. package/src/dataunit/state/action/DataUnitAction.ts +2 -0
  167. package/src/dataunit/state/slice/LoadingControlSlice.ts +42 -0
  168. package/src/dataunit/state/slice/RecordsSlice.ts +1 -1
  169. package/src/dataunit/state/slice/SelectionSlice.ts +4 -4
  170. package/src/dataunit/state/slice/test/RecordsSlice.spec.ts +45 -0
  171. package/src/dataunit/test/DataUnit.spec.ts +44 -0
  172. package/src/exceptions/ServiceCanceledException.ts +25 -0
  173. package/src/exceptions/SilentException.ts +25 -0
  174. package/src/index.ts +32 -1
  175. package/src/repository/IRepository.ts +7 -0
  176. package/src/repository/indexeddb/IDBRepository.ts +4 -0
  177. package/src/utils/Base64Utils.ts +13 -0
  178. package/src/utils/CacheManager/index.ts +103 -0
  179. package/src/utils/CacheManager/interfaces/index.ts +5 -0
  180. package/src/utils/ColumnFilterManager.ts +104 -0
  181. package/src/utils/DateUtils.ts +3 -0
  182. package/src/utils/ElementUtils.ts +10 -0
  183. package/src/utils/KeyboardManager/index.ts +57 -0
  184. package/src/utils/KeyboardManager/interface.ts +1 -0
  185. package/src/utils/LockManager.ts +207 -0
  186. package/src/utils/MaskFormatter.ts +93 -2
  187. package/src/utils/ObjectUtils.ts +77 -0
  188. package/src/utils/OnboardingUtils.ts +1 -1
  189. package/src/utils/OverflowWatcher/index.ts +243 -0
  190. package/src/utils/OverflowWatcher/types/overflow-callback.ts +6 -0
  191. package/src/utils/OverflowWatcher/types/overflow-direction.ts +7 -0
  192. package/src/utils/ServiceUtils.ts +36 -0
  193. package/src/utils/SortingUtils.ts +30 -0
  194. package/src/utils/StringUtils.ts +23 -6
  195. package/src/utils/UserAgentUtils/index.ts +6 -1
  196. package/test/dataunit/formatting/PrettyFormatter.spec.ts +177 -0
  197. package/test/dataunit/loader/dataUnitInMemoryLoader.spec.ts +221 -0
  198. package/test/dataunit/loader/utils/dataUnitLoaderUtils.spec.ts +158 -0
  199. package/test/testCases/NumberUtilsTestCases.ts +190 -0
  200. package/test/testCases/StringUtilsTestCases.ts +435 -0
  201. package/test/testCases/TimeFormatterTestUtils.ts +43 -0
  202. package/test/util/ColumnFilterManager.spec.ts +133 -0
  203. package/test/util/ElementUtils.spec.ts +34 -0
  204. package/test/util/NumberUtils.spec.ts +72 -150
  205. package/test/util/ObjectUtils.spec.ts +572 -0
  206. package/test/util/OverflowWatcher.spec.ts +152 -0
  207. package/test/util/StringUtils.spec.ts +260 -36
  208. package/test/util/TimeFormatter.spec.ts +65 -18
@@ -0,0 +1,158 @@
1
+ jest.mock('../../../../src/utils/ColumnFilterManager', () => ({
2
+ ColumnFilterManager: {
3
+ getColumnFilters: jest.fn(),
4
+ getFilterFunction: jest.fn(),
5
+ },
6
+ }));
7
+
8
+ jest.mock('../../../../src/utils/SortingUtils', () => {
9
+ return {
10
+ __esModule: true, // Indica que este módulo possui uma exportação padrão
11
+ default: {
12
+ getSortingFunction: jest.fn(),
13
+ },
14
+ };
15
+ });
16
+
17
+
18
+ import { DataUnitLoaderUtils } from '../../../../src/dataunit/loader/utils/dataUnitLoaderUtils';
19
+ import { IColumnFilter } from '../../../../src/utils/ColumnFilterManager';
20
+ import { Record } from '../../../../src/dataunit/DataUnit';
21
+ import { Filter, Sort, SortMode } from '../../../../src/dataunit/metadata/UnitMetadata';
22
+ import { DataType } from '../../../../src/dataunit/metadata/DataType';
23
+ import { ColumnFilterManager } from '../../../../src/utils/ColumnFilterManager';
24
+ import SortingUtils from '../../../../src/utils/SortingUtils';
25
+
26
+
27
+ describe('Utility Functions', () => {
28
+ beforeEach(() => {
29
+ jest.clearAllMocks();
30
+ });
31
+
32
+ describe('applyFilter', () => {
33
+ it('should return the original records if no filters are provided', () => {
34
+ const records: Record[] = [{ __record__id__: '1' }, { __record__id__: '2' }];
35
+ const filters: Filter[] = [];
36
+ const columnFilterMock = new Map<string, IColumnFilter>();
37
+
38
+ (ColumnFilterManager.getColumnFilters as jest.Mock).mockReturnValue(columnFilterMock);
39
+ (ColumnFilterManager.getFilterFunction as jest.Mock).mockReturnValue(undefined);
40
+
41
+ const result = DataUnitLoaderUtils.applyFilter(records, {} as any, filters);
42
+
43
+ expect(result).toEqual(records);
44
+ expect(ColumnFilterManager.getColumnFilters).toHaveBeenCalledWith(filters, '');
45
+ });
46
+
47
+ it('should filter records based on provided filters', () => {
48
+ const records: Record[] = [{ __record__id__: '1' }, { __record__id__: '2' }];
49
+ const filters: Filter[] = [{ name: 'test', expression: '1' }];
50
+ const columnFilterMock = new Map<string, IColumnFilter>();
51
+ columnFilterMock.set('test', { columnName: 'name', ...filters[0] } as IColumnFilter);
52
+
53
+ (ColumnFilterManager.getColumnFilters as jest.Mock).mockReturnValue(columnFilterMock);
54
+ (ColumnFilterManager.getFilterFunction as jest.Mock).mockReturnValue((record: Record) => record.__record__id__ === '1');
55
+
56
+ const result = DataUnitLoaderUtils.applyFilter(records, {} as any, filters);
57
+
58
+ expect(result).toEqual([{ __record__id__: '1' }]);
59
+ expect(ColumnFilterManager.getFilterFunction).toHaveBeenCalledWith({}, Array.from(columnFilterMock.values()));
60
+ });
61
+ });
62
+
63
+ describe('buildPaginationInfo function', () => {
64
+ it('should return correct pagination info with default values', () => {
65
+
66
+ const result = DataUnitLoaderUtils.buildPaginationInfo({
67
+ recordsLength: 0,
68
+ offset: 0,
69
+ recordsPerPage: 5,
70
+ });
71
+
72
+ expect(result).toEqual({
73
+ currentPage: 0,
74
+ firstRecord: 0,
75
+ lastRecord: 0,
76
+ total: 0,
77
+ hasMore: false,
78
+ });
79
+ });
80
+
81
+ it('should redosLenth as same size as recordsPerPage', () => {
82
+ const result = DataUnitLoaderUtils.buildPaginationInfo({
83
+ recordsLength: 10,
84
+ offset: 0,
85
+ recordsPerPage: 10,
86
+ });
87
+
88
+ expect(result).toEqual({
89
+ currentPage: 0,
90
+ firstRecord: 1,
91
+ lastRecord: 10,
92
+ total: 10,
93
+ hasMore: false,
94
+ });
95
+ });
96
+
97
+
98
+ it('should handle case when totalRecordsLength and offset 0', () => {
99
+ const result = DataUnitLoaderUtils.buildPaginationInfo({
100
+ recordsLength: 10,
101
+ offset: 0,
102
+ recordsPerPage: 5,
103
+ });
104
+
105
+ expect(result).toEqual({
106
+ currentPage: 0,
107
+ firstRecord: 1,
108
+ lastRecord: 5,
109
+ total: 10,
110
+ hasMore: true,
111
+ });
112
+ });
113
+
114
+ it('should handle case when currentPageLength is less than totalRecordsLength and lastPage', () => {
115
+ const result = DataUnitLoaderUtils.buildPaginationInfo({
116
+ recordsLength: 10,
117
+ offset: 5,
118
+ recordsPerPage: 5,
119
+ });
120
+
121
+ expect(result).toEqual({
122
+ currentPage: 1,
123
+ firstRecord: 6,
124
+ lastRecord: 10,
125
+ total: 10,
126
+ hasMore: false,
127
+ });
128
+ });
129
+ });
130
+
131
+ describe('applySorting function', () => {
132
+
133
+ it('should return the original records if no sorting is provided', () => {
134
+ const records: Record[] = [{ __record__id__: '1' }, { __record__id__: '2' }];
135
+ const sorting: Sort[] = [];
136
+
137
+ const result = DataUnitLoaderUtils.applySorting(records, {} as any, sorting);
138
+
139
+ expect(result).toEqual(records);
140
+ expect(SortingUtils.getSortingFunction).not.toHaveBeenCalled();
141
+ });
142
+
143
+ it('should sort records based on provided sorting criteria', () => {
144
+ const records: Record[] = [{ __record__id__: '2' }, { __record__id__: '1' }];
145
+ const sorting: Sort[] = [{ field: '__record__id__', mode: SortMode.ASC, dataType: DataType.TEXT }];
146
+
147
+ const sortingFunction = (a: Record, b: Record) => (a.__record__id__ > b.__record__id__ ? 1 : -1);
148
+ (SortingUtils.getSortingFunction as jest.Mock).mockReturnValue(sortingFunction);
149
+
150
+ const result = DataUnitLoaderUtils.applySorting(records, {} as any, sorting);
151
+
152
+ expect(result).toEqual([{ __record__id__: '1' }, { __record__id__: '2' }]);
153
+ expect(SortingUtils.getSortingFunction).toHaveBeenCalledWith({}, sorting);
154
+ });
155
+ });
156
+
157
+
158
+ });
@@ -0,0 +1,190 @@
1
+ export const stringToNumberCases = [
2
+ { valueInput: '100', valueOutput: 100 },
3
+ { valueInput: '100,12', valueOutput: 100.12 },
4
+ { valueInput: '11500,12', valueOutput: 11500.12 },
5
+ { valueInput: '11500', valueOutput: 11500 },
6
+ { valueInput: '1.000', valueOutput: 1 },
7
+ { valueInput: '11.500,003', valueOutput: 11500.003 },
8
+ { valueInput: '-100', valueOutput: -100 },
9
+ { valueInput: '-100,12', valueOutput: -100.12 },
10
+ { valueInput: '-11500,1', valueOutput: -11500.1 },
11
+ { valueInput: '-11500', valueOutput: -11500 },
12
+ { valueInput: '-11.500,003', valueOutput: -11500.003 },
13
+ { valueInput: 'R$100', valueOutput: 100 },
14
+ { valueInput: 'R$100,12', valueOutput: 100.12 },
15
+ { valueInput: 'R$11500,12', valueOutput: 11500.12 },
16
+ { valueInput: 'R$11500', valueOutput: 11500 },
17
+ { valueInput: 'R$11.500,003', valueOutput: 11500.003 },
18
+ { valueInput: '-R$100', valueOutput: -100 },
19
+ { valueInput: '-R$100,12', valueOutput: -100.12 },
20
+ { valueInput: '-R$11500,12', valueOutput: -11500.12 },
21
+ { valueInput: '-R$11500', valueOutput: -11500 },
22
+ { valueInput: '-R$11.500,003', valueOutput: -11500.003 },
23
+ { valueInput: '', valueOutput: NaN },
24
+ { valueInput: 'OrdinaryString', valueOutput: NaN },
25
+ { valueInput: '100.167.80', valueOutput: NaN },
26
+ { valueInput: 'uahsuhas,auhsuhasu', valueOutput: NaN },
27
+ { valueInput: '100,100,100', valueOutput: NaN },
28
+ { valueInput: 'OrdinaryString,.OrdinaryString', valueOutput: NaN },
29
+ { valueInput: 'OrdinaryString.,OrdinaryString', valueOutput: NaN },
30
+ { valueInput: '.121212', valueOutput: 0.121212 },
31
+ { valueInput: ',121212', valueOutput: 0.121212 },
32
+ { valueInput: '1,232,333.345', valueOutput: NaN },
33
+ { valueInput: '1232333,345', valueOutput: 1232333.345 },
34
+ ]
35
+
36
+ export const formatCases = [
37
+
38
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
39
+ { precision: 2, prettyprecision: 1, strvalue: '1.000', strvalueOutPut: '1,0' },
40
+ { precision: 2, prettyprecision: 1, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
41
+ { precision: 4, prettyprecision: 2, strvalue: '1,232,333.345', strvalueOutPut: 'NaN' },
42
+ { precision: 2, prettyprecision: 1, strvalue: '1,23', strvalueOutPut: '1,23' },
43
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999', strvalueOutPut: 'NaN' },
44
+ { precision: 4, prettyprecision: 0, strvalue: '1200.00001', strvalueOutPut: '1.200' },
45
+ { precision: 4, prettyprecision: 0, strvalue: 'String', strvalueOutPut: 'NaN' },
46
+ { precision: 4, prettyprecision: 0, strvalue: '', strvalueOutPut: 'NaN' },
47
+
48
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
49
+ { precision: 2, prettyprecision: undefined, strvalue: '1.000', strvalueOutPut: '1,00' },
50
+ { precision: 2, prettyprecision: undefined, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
51
+ { precision: 4, prettyprecision: undefined, strvalue: '1,232,333.345', strvalueOutPut: 'NaN' },
52
+ { precision: 2, prettyprecision: undefined, strvalue: '1,23', strvalueOutPut: '1,23' },
53
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999', strvalueOutPut: 'NaN' },
54
+ { precision: 4, prettyprecision: undefined, strvalue: 'NaN', strvalueOutPut: 'NaN' },
55
+
56
+
57
+ { precision: 1, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,2' },
58
+ { precision: 1, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,1' },
59
+ { precision: 1, prettyprecision: 1.3, strvalue: '111,100', strvalueOutPut: '111,1' },
60
+ { precision: -1, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
61
+ { precision: -1, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
62
+ { precision: 1.2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
63
+
64
+
65
+ { precision: 2, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,20' },
66
+ { precision: 2, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,10' },
67
+ { precision: -2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
68
+ { precision: -2, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
69
+
70
+
71
+ ];
72
+
73
+ export const changeFormatCases = [
74
+ { inputValue: '1.200.999', outPutValue: '1,200,999' },
75
+ { inputValue: '1.000,99', outPutValue: '1,000.99' },
76
+ { inputValue: '1200999,99', outPutValue: '1200999.99' },
77
+ { inputValue: 'R$ 1,232,333.345', outPutValue: 'R$ 1.232.333,345' },
78
+ { inputValue: 'R$ 1.232.333,345', outPutValue: 'R$ 1,232,333.345' },
79
+ ]
80
+
81
+ export const keepOnlyDecimalSeparatorCases = [
82
+
83
+ { formatnumber: 'pt-BR', inputValue: '1.200.999', outPutValue: '1200999' },
84
+ { formatnumber: 'pt-BR', inputValue: '1000,99', outPutValue: '1000,99' },
85
+ { formatnumber: 'pt-BR', inputValue: '1200999,99', outPutValue: '1200999,99' },
86
+ { formatnumber: 'pt-BR', inputValue: 'R$ 1.232.333,345', outPutValue: 'R$ 1232333,345' },
87
+
88
+ { formatnumber: 'en-US', inputValue: '1,200,999', outPutValue: '1200999' },
89
+ { formatnumber: 'en-US', inputValue: '1,000.99', outPutValue: '1000.99' },
90
+ { formatnumber: 'en-US', inputValue: '1200999.99', outPutValue: '1200999.99' },
91
+ { formatnumber: 'en-US', inputValue: 'EUR 1,232,333.345', outPutValue: 'EUR 1232333.345' },
92
+
93
+
94
+ ];
95
+
96
+ export const roundTestCases = [
97
+ { decimal: undefined, inputValue: 100.12, outPutValue: 100.12 },
98
+ { decimal: 1, inputValue: 100.12, outPutValue: 100.1 },
99
+ { decimal: 2, inputValue: 100.12, outPutValue: 100.12 },
100
+ { decimal: 3, inputValue: 100.12, outPutValue: 100.12 },
101
+ { decimal: 1, inputValue: 100.15, outPutValue: 100.2 },
102
+ { decimal: 2, inputValue: 100.15, outPutValue: 100.15 },
103
+ { decimal: 3, inputValue: 100.15, outPutValue: 100.15 },
104
+ { decimal: 1, inputValue: 100.16, outPutValue: 100.2 },
105
+ { decimal: 2, inputValue: 100.16, outPutValue: 100.16 },
106
+ { decimal: 3, inputValue: 100.16, outPutValue: 100.16 },
107
+ { decimal: 12, inputValue: 2118000000000.0002, outPutValue: 2118000000000.0002 },
108
+ { decimal: 5, inputValue: 123.45, outPutValue: 123.45 },
109
+ { decimal: 0, inputValue: 123.45, outPutValue: 123 },
110
+ ];
111
+
112
+ export const safeFormatCases = [
113
+
114
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
115
+ { precision: 2, prettyprecision: 1, strvalue: '1.000', strvalueOutPut: '1,0' },
116
+ { precision: 2, prettyprecision: 1, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
117
+ { precision: 4, prettyprecision: 2, strvalue: '1,232,333.345', strvalueOutPut: '0,00' },
118
+ { precision: 2, prettyprecision: 1, strvalue: '1,23', strvalueOutPut: '1,23' },
119
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999', strvalueOutPut: '0,00' },
120
+ { precision: 4, prettyprecision: 0, strvalue: '1200.00001', strvalueOutPut: '1.200' },
121
+ { precision: 4, prettyprecision: 0, strvalue: 'String', strvalueOutPut: '0,00' },
122
+ { precision: 4, prettyprecision: 0, strvalue: '', strvalueOutPut: '0,00' },
123
+
124
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
125
+ { precision: 2, prettyprecision: undefined, strvalue: '1.000', strvalueOutPut: '1,00' },
126
+ { precision: 2, prettyprecision: undefined, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
127
+ { precision: 4, prettyprecision: undefined, strvalue: '1,232,333.345', strvalueOutPut: '0,00' },
128
+ { precision: 2, prettyprecision: undefined, strvalue: '1,23', strvalueOutPut: '1,23' },
129
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999', strvalueOutPut: '0,00' },
130
+ { precision: 4, prettyprecision: undefined, strvalue: 'NaN', strvalueOutPut: '0,00' },
131
+
132
+
133
+ { precision: 1, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,2' },
134
+ { precision: 1, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,1' },
135
+ { precision: 1, prettyprecision: 1.3, strvalue: '111,100', strvalueOutPut: '111,1' },
136
+ { precision: -1, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
137
+ { precision: -1, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
138
+ { precision: 1.2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
139
+
140
+
141
+ { precision: 2, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,20' },
142
+ { precision: 2, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,10' },
143
+ { precision: -2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
144
+ { precision: -2, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
145
+ ];
146
+
147
+ export const getValueOrDefaultCases = [
148
+ { value: undefined, defaultValue: 0, expected: 0 },
149
+ { value: null, defaultValue: 10, expected: 10 },
150
+ { value: '', defaultValue: 5, expected: 5 },
151
+ { value: ' ', defaultValue: 7, expected: 7 },
152
+ { value: '123', defaultValue: 0, expected: 123 },
153
+ { value: '-123', defaultValue: 0, expected: -123 },
154
+ { value: '123.45', defaultValue: 0, expected: 123.45 },
155
+ { value: 'abc', defaultValue: 8, expected: 8 },
156
+ { value: 'NaN', defaultValue: 15, expected: 15 },
157
+ { value: '0', defaultValue: 5, expected: 0 },
158
+ { value: 42, defaultValue: 0, expected: 42 },
159
+ { value: -42, defaultValue: 0, expected: -42 },
160
+ { value: 0, defaultValue: 100, expected: 0 },
161
+ { value: NaN, defaultValue: 50, expected: 50 },
162
+ ];
163
+
164
+ export const getValueOrZeroCases = [
165
+ { value: undefined, expected: 0 },
166
+ { value: null, expected: 0 },
167
+ { value: '', expected: 0 },
168
+ { value: ' ', expected: 0 },
169
+ { value: '123', expected: 123 },
170
+ { value: '-123', expected: -123 },
171
+ { value: '123.45', expected: 123.45 },
172
+ { value: 'abc', expected: 0 },
173
+ { value: 'NaN', expected: 0 },
174
+ { value: '0', expected: 0 },
175
+ { value: 42, expected: 42 },
176
+ { value: -42, expected: -42 },
177
+ { value: 0, expected: 0 },
178
+ { value: NaN, expected: 0 },
179
+ ];
180
+
181
+ export const compareCases = [
182
+ { a: 10, b: 5, expected: 1 },
183
+ { a: 5, b: 10, expected: -1 },
184
+ { a: 5, b: 5, expected: 0 },
185
+ { a: -10, b: -5, expected: -1 },
186
+ { a: -5, b: -10, expected: 1 },
187
+ { a: 0, b: 0, expected: 0 },
188
+ { a: 0, b: -1, expected: 1 },
189
+ { a: -1, b: 0, expected: -1 },
190
+ ];