@sankhyalabs/core 0.0.0-bugfix-dev-KB-6165.0

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 (283) hide show
  1. package/.docs/.nojekyll +1 -0
  2. package/.docs/README.md +63 -0
  3. package/.docs/classes/ApplicationContext.md +90 -0
  4. package/.docs/classes/ArrayUtils.md +99 -0
  5. package/.docs/classes/AuthorizedServiceCaller.md +76 -0
  6. package/.docs/classes/Change.md +190 -0
  7. package/.docs/classes/DataUnit.md +2453 -0
  8. package/.docs/classes/DataUnitAction.md +96 -0
  9. package/.docs/classes/DataUnitStorage.md +116 -0
  10. package/.docs/classes/DateUtils.md +327 -0
  11. package/.docs/classes/ElementIDUtils.md +308 -0
  12. package/.docs/classes/ErrorException.md +214 -0
  13. package/.docs/classes/ErrorTracking.md +62 -0
  14. package/.docs/classes/FloatingManager.md +530 -0
  15. package/.docs/classes/HTMLBuilder.md +45 -0
  16. package/.docs/classes/HttpProvider.md +96 -0
  17. package/.docs/classes/JSUtils.md +115 -0
  18. package/.docs/classes/MaskFormatter-1.md +347 -0
  19. package/.docs/classes/NumberUtils.md +335 -0
  20. package/.docs/classes/ObjectUtils.md +160 -0
  21. package/.docs/classes/OnboardingUtils.md +126 -0
  22. package/.docs/classes/PromiseSync.md +91 -0
  23. package/.docs/classes/ReadyUtil.md +115 -0
  24. package/.docs/classes/RequestMetadata.md +84 -0
  25. package/.docs/classes/SelectionInfo.md +168 -0
  26. package/.docs/classes/SkwHttpProvider.md +109 -0
  27. package/.docs/classes/StringUtils.md +562 -0
  28. package/.docs/classes/TimeFormatter.md +98 -0
  29. package/.docs/classes/UserAgentUtils.md +58 -0
  30. package/.docs/classes/VersionUtils.md +42 -0
  31. package/.docs/classes/WaitingChangeException.md +200 -0
  32. package/.docs/classes/WarningException.md +214 -0
  33. package/.docs/enums/Action.md +294 -0
  34. package/.docs/enums/ChangeOperation.md +52 -0
  35. package/.docs/enums/DataType.md +63 -0
  36. package/.docs/enums/DependencyType.md +41 -0
  37. package/.docs/enums/SelectionMode.md +30 -0
  38. package/.docs/enums/SortMode.md +30 -0
  39. package/.docs/enums/UserInterface.md +195 -0
  40. package/.docs/interfaces/ChildDescriptor.md +41 -0
  41. package/.docs/interfaces/ChildLink.md +30 -0
  42. package/.docs/interfaces/DUActionInterceptor.md +29 -0
  43. package/.docs/interfaces/ExecutionContext.md +58 -0
  44. package/.docs/interfaces/FieldDescriptor.md +140 -0
  45. package/.docs/interfaces/Filter.md +41 -0
  46. package/.docs/interfaces/IElementIDInfo.md +30 -0
  47. package/.docs/interfaces/LoadDataRequest.md +101 -0
  48. package/.docs/interfaces/LoadDataResponse.md +36 -0
  49. package/.docs/interfaces/PageRequest.md +41 -0
  50. package/.docs/interfaces/PaginationInfo.md +75 -0
  51. package/.docs/interfaces/PromiseSyncCallback.md +39 -0
  52. package/.docs/interfaces/QuickFilter.md +41 -0
  53. package/.docs/interfaces/Record.md +62 -0
  54. package/.docs/interfaces/SavedRecord.md +85 -0
  55. package/.docs/interfaces/Sort.md +41 -0
  56. package/.docs/interfaces/SortingProvider.md +29 -0
  57. package/.docs/interfaces/UnitMetadata.md +52 -0
  58. package/.docs/interfaces/WaitingChange.md +41 -0
  59. package/.docs/modules/MaskFormatter.md +37 -0
  60. package/.docs/modules.md +74 -0
  61. package/.docs/package.json +15 -0
  62. package/.eslintignore +2 -0
  63. package/.eslintrc.cjs +35 -0
  64. package/.husky/commit-msg +4 -0
  65. package/.releaserc +58 -0
  66. package/README.md +62 -0
  67. package/commitlint.config.cjs +14 -0
  68. package/dist/async/PromiseSync.d.ts +29 -0
  69. package/dist/async/PromiseSync.js +31 -0
  70. package/dist/async/PromiseSync.js.map +1 -0
  71. package/dist/dataunit/DataUnit.d.ts +924 -0
  72. package/dist/dataunit/DataUnit.js +1621 -0
  73. package/dist/dataunit/DataUnit.js.map +1 -0
  74. package/dist/dataunit/DataUnitStorage.d.ts +24 -0
  75. package/dist/dataunit/DataUnitStorage.js +39 -0
  76. package/dist/dataunit/DataUnitStorage.js.map +1 -0
  77. package/dist/dataunit/formatting/PrettyFormatter.d.ts +2 -0
  78. package/dist/dataunit/formatting/PrettyFormatter.js +94 -0
  79. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -0
  80. package/dist/dataunit/loading/LoadDataRequest.d.ts +19 -0
  81. package/dist/dataunit/loading/LoadDataRequest.js +2 -0
  82. package/dist/dataunit/loading/LoadDataRequest.js.map +1 -0
  83. package/dist/dataunit/loading/LoadDataResponse.d.ts +9 -0
  84. package/dist/dataunit/loading/LoadDataResponse.js +2 -0
  85. package/dist/dataunit/loading/LoadDataResponse.js.map +1 -0
  86. package/dist/dataunit/loading/PaginationInfo.d.ts +13 -0
  87. package/dist/dataunit/loading/PaginationInfo.js +2 -0
  88. package/dist/dataunit/loading/PaginationInfo.js.map +1 -0
  89. package/dist/dataunit/metadata/DataType.d.ts +54 -0
  90. package/dist/dataunit/metadata/DataType.js +124 -0
  91. package/dist/dataunit/metadata/DataType.js.map +1 -0
  92. package/dist/dataunit/metadata/UnitMetadata.d.ts +88 -0
  93. package/dist/dataunit/metadata/UnitMetadata.js +36 -0
  94. package/dist/dataunit/metadata/UnitMetadata.js.map +1 -0
  95. package/dist/dataunit/state/HistReducer.d.ts +10 -0
  96. package/dist/dataunit/state/HistReducer.js +28 -0
  97. package/dist/dataunit/state/HistReducer.js.map +1 -0
  98. package/dist/dataunit/state/StateManager.d.ts +57 -0
  99. package/dist/dataunit/state/StateManager.js +97 -0
  100. package/dist/dataunit/state/StateManager.js.map +1 -0
  101. package/dist/dataunit/state/action/DataUnitAction.d.ts +40 -0
  102. package/dist/dataunit/state/action/DataUnitAction.js +42 -0
  103. package/dist/dataunit/state/action/DataUnitAction.js.map +1 -0
  104. package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +12 -0
  105. package/dist/dataunit/state/slice/AddedRecordsSlice.js +30 -0
  106. package/dist/dataunit/state/slice/AddedRecordsSlice.js.map +1 -0
  107. package/dist/dataunit/state/slice/ChangesSlice.d.ts +13 -0
  108. package/dist/dataunit/state/slice/ChangesSlice.js +105 -0
  109. package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -0
  110. package/dist/dataunit/state/slice/InvalidFieldsSlice.d.ts +10 -0
  111. package/dist/dataunit/state/slice/InvalidFieldsSlice.js +66 -0
  112. package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -0
  113. package/dist/dataunit/state/slice/LoadingControlSlice.d.ts +19 -0
  114. package/dist/dataunit/state/slice/LoadingControlSlice.js +45 -0
  115. package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -0
  116. package/dist/dataunit/state/slice/RecordsSlice.d.ts +11 -0
  117. package/dist/dataunit/state/slice/RecordsSlice.js +62 -0
  118. package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -0
  119. package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -0
  120. package/dist/dataunit/state/slice/RemovedRecordsSlice.js +25 -0
  121. package/dist/dataunit/state/slice/RemovedRecordsSlice.js.map +1 -0
  122. package/dist/dataunit/state/slice/SelectionSlice.d.ts +19 -0
  123. package/dist/dataunit/state/slice/SelectionSlice.js +155 -0
  124. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -0
  125. package/dist/dataunit/state/slice/SnapshotSlice.d.ts +19 -0
  126. package/dist/dataunit/state/slice/SnapshotSlice.js +106 -0
  127. package/dist/dataunit/state/slice/SnapshotSlice.js.map +1 -0
  128. package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -0
  129. package/dist/dataunit/state/slice/UnitMetadataSlice.js +21 -0
  130. package/dist/dataunit/state/slice/UnitMetadataSlice.js.map +1 -0
  131. package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +12 -0
  132. package/dist/dataunit/state/slice/WaitingChangesSlice.js +56 -0
  133. package/dist/dataunit/state/slice/WaitingChangesSlice.js.map +1 -0
  134. package/dist/exceptions/ErrorException.d.ts +14 -0
  135. package/dist/exceptions/ErrorException.js +13 -0
  136. package/dist/exceptions/ErrorException.js.map +1 -0
  137. package/dist/exceptions/WaitingChangeException.d.ts +12 -0
  138. package/dist/exceptions/WaitingChangeException.js +12 -0
  139. package/dist/exceptions/WaitingChangeException.js.map +1 -0
  140. package/dist/exceptions/WarningException.d.ts +14 -0
  141. package/dist/exceptions/WarningException.js +13 -0
  142. package/dist/exceptions/WarningException.js.map +1 -0
  143. package/dist/html/HTMLBuilder.d.ts +3 -0
  144. package/dist/html/HTMLBuilder.js +9 -0
  145. package/dist/html/HTMLBuilder.js.map +1 -0
  146. package/dist/http/AuthorizedServiceCaller.d.ts +11 -0
  147. package/dist/http/AuthorizedServiceCaller.js +54 -0
  148. package/dist/http/AuthorizedServiceCaller.js.map +1 -0
  149. package/dist/http/HttpProvider.d.ts +25 -0
  150. package/dist/http/HttpProvider.js +74 -0
  151. package/dist/http/HttpProvider.js.map +1 -0
  152. package/dist/http/RequestMetadata.d.ts +30 -0
  153. package/dist/http/RequestMetadata.js +25 -0
  154. package/dist/http/RequestMetadata.js.map +1 -0
  155. package/dist/http/SkwHttpProvider.d.ts +9 -0
  156. package/dist/http/SkwHttpProvider.js +67 -0
  157. package/dist/http/SkwHttpProvider.js.map +1 -0
  158. package/dist/index.d.ts +34 -0
  159. package/dist/index.js +33 -0
  160. package/dist/index.js.map +1 -0
  161. package/dist/traking/ErrorTraking.d.ts +19 -0
  162. package/dist/traking/ErrorTraking.js +34 -0
  163. package/dist/traking/ErrorTraking.js.map +1 -0
  164. package/dist/ui/FloatingManager.d.ts +164 -0
  165. package/dist/ui/FloatingManager.js +358 -0
  166. package/dist/ui/FloatingManager.js.map +1 -0
  167. package/dist/utils/ApplicationContext.d.ts +26 -0
  168. package/dist/utils/ApplicationContext.js +38 -0
  169. package/dist/utils/ApplicationContext.js.map +1 -0
  170. package/dist/utils/ArrayUtils.d.ts +29 -0
  171. package/dist/utils/ArrayUtils.js +57 -0
  172. package/dist/utils/ArrayUtils.js.map +1 -0
  173. package/dist/utils/CriteriaModel.d.ts +107 -0
  174. package/dist/utils/CriteriaModel.js +172 -0
  175. package/dist/utils/CriteriaModel.js.map +1 -0
  176. package/dist/utils/CriteriaParameter.d.ts +69 -0
  177. package/dist/utils/CriteriaParameter.js +83 -0
  178. package/dist/utils/CriteriaParameter.js.map +1 -0
  179. package/dist/utils/DateUtils.d.ts +97 -0
  180. package/dist/utils/DateUtils.js +171 -0
  181. package/dist/utils/DateUtils.js.map +1 -0
  182. package/dist/utils/ElementIDUtils.d.ts +72 -0
  183. package/dist/utils/ElementIDUtils.js +161 -0
  184. package/dist/utils/ElementIDUtils.js.map +1 -0
  185. package/dist/utils/JSUtils.d.ts +36 -0
  186. package/dist/utils/JSUtils.js +66 -0
  187. package/dist/utils/JSUtils.js.map +1 -0
  188. package/dist/utils/MaskFormatter.d.ts +148 -0
  189. package/dist/utils/MaskFormatter.js +356 -0
  190. package/dist/utils/MaskFormatter.js.map +1 -0
  191. package/dist/utils/NumberUtils.d.ts +127 -0
  192. package/dist/utils/NumberUtils.js +245 -0
  193. package/dist/utils/NumberUtils.js.map +1 -0
  194. package/dist/utils/ObjectUtils.d.ts +47 -0
  195. package/dist/utils/ObjectUtils.js +68 -0
  196. package/dist/utils/ObjectUtils.js.map +1 -0
  197. package/dist/utils/OnboardingUtils.d.ts +17 -0
  198. package/dist/utils/OnboardingUtils.js +41 -0
  199. package/dist/utils/OnboardingUtils.js.map +1 -0
  200. package/dist/utils/ReadyUtil.d.ts +24 -0
  201. package/dist/utils/ReadyUtil.js +41 -0
  202. package/dist/utils/ReadyUtil.js.map +1 -0
  203. package/dist/utils/StringUtils.d.ts +167 -0
  204. package/dist/utils/StringUtils.js +328 -0
  205. package/dist/utils/StringUtils.js.map +1 -0
  206. package/dist/utils/TimeFormatter.d.ts +33 -0
  207. package/dist/utils/TimeFormatter.js +98 -0
  208. package/dist/utils/TimeFormatter.js.map +1 -0
  209. package/dist/utils/UserAgentUtils/index.d.ts +15 -0
  210. package/dist/utils/UserAgentUtils/index.js +48 -0
  211. package/dist/utils/UserAgentUtils/index.js.map +1 -0
  212. package/dist/utils/UserAgentUtils/navigatorAgentList.d.ts +17 -0
  213. package/dist/utils/UserAgentUtils/navigatorAgentList.js +40 -0
  214. package/dist/utils/UserAgentUtils/navigatorAgentList.js.map +1 -0
  215. package/dist/utils/VersionUtils.d.ts +7 -0
  216. package/dist/utils/VersionUtils.js +31 -0
  217. package/dist/utils/VersionUtils.js.map +1 -0
  218. package/jest.config.ts +17 -0
  219. package/mock/http/XMLHttpRequest-mock.js +26 -0
  220. package/package.json +52 -0
  221. package/scripts/runlink.bat +1 -0
  222. package/scripts/runlink.sh +1 -0
  223. package/src/async/PromiseSync.ts +49 -0
  224. package/src/dataunit/DataUnit.ts +1835 -0
  225. package/src/dataunit/DataUnitStorage.ts +43 -0
  226. package/src/dataunit/formatting/PrettyFormatter.ts +113 -0
  227. package/src/dataunit/loading/LoadDataRequest.ts +26 -0
  228. package/src/dataunit/loading/LoadDataResponse.ts +11 -0
  229. package/src/dataunit/loading/PaginationInfo.ts +18 -0
  230. package/src/dataunit/metadata/DataType.ts +127 -0
  231. package/src/dataunit/metadata/UnitMetadata.ts +102 -0
  232. package/src/dataunit/state/HistReducer.ts +34 -0
  233. package/src/dataunit/state/StateManager.ts +142 -0
  234. package/src/dataunit/state/action/DataUnitAction.ts +67 -0
  235. package/src/dataunit/state/slice/AddedRecordsSlice.ts +48 -0
  236. package/src/dataunit/state/slice/ChangesSlice.ts +125 -0
  237. package/src/dataunit/state/slice/InvalidFieldsSlice.ts +85 -0
  238. package/src/dataunit/state/slice/LoadingControlSlice.ts +60 -0
  239. package/src/dataunit/state/slice/RecordsSlice.ts +74 -0
  240. package/src/dataunit/state/slice/RemovedRecordsSlice.ts +30 -0
  241. package/src/dataunit/state/slice/SelectionSlice.ts +193 -0
  242. package/src/dataunit/state/slice/SnapshotSlice.ts +139 -0
  243. package/src/dataunit/state/slice/UnitMetadataSlice.ts +30 -0
  244. package/src/dataunit/state/slice/WaitingChangesSlice.ts +74 -0
  245. package/src/exceptions/ErrorException.ts +25 -0
  246. package/src/exceptions/WaitingChangeException.ts +21 -0
  247. package/src/exceptions/WarningException.ts +26 -0
  248. package/src/html/HTMLBuilder.ts +8 -0
  249. package/src/http/AuthorizedServiceCaller.ts +58 -0
  250. package/src/http/HttpProvider.ts +94 -0
  251. package/src/http/RequestMetadata.ts +42 -0
  252. package/src/http/SkwHttpProvider.ts +78 -0
  253. package/src/index.ts +93 -0
  254. package/src/traking/ErrorTraking.ts +37 -0
  255. package/src/ui/FloatingManager.ts +417 -0
  256. package/src/utils/ApplicationContext.ts +42 -0
  257. package/src/utils/ArrayUtils.ts +61 -0
  258. package/src/utils/CriteriaModel.ts +205 -0
  259. package/src/utils/CriteriaParameter.ts +108 -0
  260. package/src/utils/DateUtils.ts +195 -0
  261. package/src/utils/ElementIDUtils.ts +184 -0
  262. package/src/utils/JSUtils.ts +69 -0
  263. package/src/utils/MaskFormatter.ts +407 -0
  264. package/src/utils/NumberUtils.ts +283 -0
  265. package/src/utils/ObjectUtils.ts +76 -0
  266. package/src/utils/OnboardingUtils.ts +46 -0
  267. package/src/utils/ReadyUtil.ts +45 -0
  268. package/src/utils/StringUtils.ts +359 -0
  269. package/src/utils/TimeFormatter.ts +98 -0
  270. package/src/utils/UserAgentUtils/index.ts +62 -0
  271. package/src/utils/UserAgentUtils/navigatorAgentList.ts +39 -0
  272. package/src/utils/VersionUtils.ts +37 -0
  273. package/test/http/HttpProvider.spec.ts +35 -0
  274. package/test/http/SkwHttpProvider.ts.spec.ts +34 -0
  275. package/test/util/CriteriaModel.spec.ts +232 -0
  276. package/test/util/CriteriaParameter.spec.ts +52 -0
  277. package/test/util/DataUnitStorage.spec.ts +63 -0
  278. package/test/util/ElementIDUtils.spec.ts +272 -0
  279. package/test/util/MaskFormatter.spec.ts +138 -0
  280. package/test/util/NumberUtils.spec.ts +182 -0
  281. package/test/util/StringUtils.spec.ts +51 -0
  282. package/test/util/TimeFormatter.spec.ts +26 -0
  283. package/tsconfig.json +16 -0
@@ -0,0 +1,138 @@
1
+ import { MaskFormatter } from '../../src/utils/MaskFormatter';
2
+
3
+ describe('Mask Formatter', () => {
4
+
5
+ //CPF--------------------------------------
6
+ it('mask:CPF complete valid', async () => {
7
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
8
+ expect(mf.format("12345678901")).toEqual("123.456.789-01");
9
+ });
10
+
11
+ it('mask:CPF complete valid literals', async () => {
12
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
13
+ expect(mf.format("123.456.789-01")).toEqual("123.456.789-01");
14
+ });
15
+
16
+ it('mask:CPF incomplete valid', async () => {
17
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
18
+ expect(mf.format("123456")).toEqual("123.456. - ");
19
+ });
20
+
21
+ it('mask:CPF incomplete valid placeholder', async () => {
22
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
23
+ mf.placeholder = "_";
24
+ expect(mf.format("123456")).toEqual("123.456.___-__");
25
+ });
26
+
27
+ it('mask:CPF too long valid', async () => {
28
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
29
+ expect(mf.format("012345678901")).toEqual("012.345.678-90");
30
+ });
31
+
32
+ it('mask:CPF invalid for string', async () => {
33
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
34
+ expect(() => { mf.format("aaaaaaaaaaa"); }).toThrowError();
35
+ });
36
+
37
+ it('mask:CPF invalid for being too long', async () => {
38
+ const mf: MaskFormatter = new MaskFormatter("###.###.###-##");
39
+ expect(mf.format("10018297609")).toEqual("100.182.976-09");
40
+ });
41
+
42
+
43
+
44
+ //Car's Licence plate
45
+ it('mask:Licence plate valid uppercase', async () => {
46
+ const mf: MaskFormatter = new MaskFormatter("UUU-####");
47
+ expect(mf.format("zzz1234")).toEqual("ZZZ-1234");
48
+ });
49
+
50
+ it('mask:Licence plate valid lowercase', async () => {
51
+ const mf: MaskFormatter = new MaskFormatter("LLL-####");
52
+ expect(mf.format("ABC1234")).toEqual("abc-1234");
53
+ });
54
+
55
+ it('mask:Licence plate invalid', async () => {
56
+ const mf: MaskFormatter = new MaskFormatter("UUU-####");
57
+ expect(() => { mf.format("ABCD1234"); }).toThrowError();
58
+ });
59
+
60
+ it('mask:Licence plate invalid for being too short', async () => {
61
+ const mf: MaskFormatter = new MaskFormatter("UUU-####");
62
+ expect(mf.format("ABC123")).toEqual("ABC-123 ");
63
+ });
64
+
65
+
66
+ it('mask:Licence plate invalid for being too short with placeholder', async () => {
67
+ const mf: MaskFormatter = new MaskFormatter("UUU-####");
68
+ mf.placeholder = "_";
69
+ expect(mf.format("ABC123")).toEqual("ABC-123_");
70
+ });
71
+
72
+
73
+ it('mask:Licence plate invalid', async () => {
74
+ const mf: MaskFormatter = new MaskFormatter("UUU-####");
75
+ expect(() => { mf.format("1111111"); }).toThrowError();
76
+ });
77
+
78
+
79
+ //Alphanumerical Value
80
+ it('mask:Licence plate with AlphaNumerical Mask', async () => {
81
+ const mf: MaskFormatter = new MaskFormatter("AAA-####");
82
+ expect(mf.format("ABC123")).toEqual("ABC-123 ");
83
+ });
84
+
85
+
86
+ it('mask:Licence plate with AlphaNumerical Mask with placeholder', async () => {
87
+ const mf: MaskFormatter = new MaskFormatter("AAA-####");
88
+ mf.placeholder = "_";
89
+ expect(mf.format("ABC123")).toEqual("ABC-123_");
90
+ });
91
+
92
+ it('mask:Licence plate invalid', async () => {
93
+ const mf: MaskFormatter = new MaskFormatter("AAA-####");
94
+ expect(() => { mf.format("#3"); }).toThrowError();
95
+ });
96
+
97
+
98
+ //Character Value
99
+ it('mask:Licence plate with AlphaNumerical Mask', async () => {
100
+ const mf: MaskFormatter = new MaskFormatter("???-####");
101
+ expect(mf.format("ABC123")).toEqual("ABC-123 ");
102
+ });
103
+
104
+
105
+ it('mask:Licence plate with AlphaNumerical Mask with placeholder', async () => {
106
+ const mf: MaskFormatter = new MaskFormatter("???-####");
107
+ mf.placeholder = "_";
108
+ expect(mf.format("ABC123")).toEqual("ABC-123_");
109
+ });
110
+
111
+
112
+ it('mask:Licence plate invalid', async () => {
113
+ const mf: MaskFormatter = new MaskFormatter("???-####");
114
+ expect(() => { mf.format("111DDD"); }).toThrowError();
115
+ });
116
+
117
+
118
+
119
+ //Anything Value
120
+ it('mask:Licence plate with AlphaNumerical Mask', async () => {
121
+ const mf: MaskFormatter = new MaskFormatter("***-####");
122
+ expect(mf.format("ABC123")).toEqual("ABC-123 ");
123
+ });
124
+
125
+
126
+ it('mask:Licence plate with AlphaNumerical Mask with placeholder', async () => {
127
+ const mf: MaskFormatter = new MaskFormatter("***-####");
128
+ mf.placeholder = "_";
129
+ expect(mf.format("ABC123")).toEqual("ABC-123_");
130
+ });
131
+
132
+ it('mask:Licence plate invalid', async () => {
133
+ const mf: MaskFormatter = new MaskFormatter("***-####");
134
+ expect(() => { mf.format("111DDD"); }).toThrowError();
135
+ });
136
+
137
+
138
+ });
@@ -0,0 +1,182 @@
1
+ import { NumberUtils } from '../../src/utils/NumberUtils';
2
+
3
+ describe('StringUtils', function () {
4
+
5
+
6
+ // => STRING_TO_NUMBER
7
+ // ----------------------------------------------------------------------------------------
8
+
9
+ const arrayDataTest = [
10
+ { valueInput: '100', valueOutput: 100 },
11
+ { valueInput: '100,12', valueOutput: 100.12 },
12
+ { valueInput: '11500,12', valueOutput: 11500.12 },
13
+ { valueInput: '11500', valueOutput: 11500 },
14
+ { valueInput: '1.000', valueOutput: 1 },
15
+ { valueInput: '11.500,003', valueOutput: 11500.003 },
16
+ { valueInput: '-100', valueOutput: -100 },
17
+ { valueInput: '-100,12', valueOutput: -100.12 },
18
+ { valueInput: '-11500,1', valueOutput: -11500.1 },
19
+ { valueInput: '-11500', valueOutput: -11500 },
20
+ { valueInput: '-11.500,003', valueOutput: -11500.003 },
21
+ { valueInput: 'R$100', valueOutput: 100 },
22
+ { valueInput: 'R$100,12', valueOutput: 100.12 },
23
+ { valueInput: 'R$11500,12', valueOutput: 11500.12 },
24
+ { valueInput: 'R$11500', valueOutput: 11500 },
25
+ { valueInput: 'R$11.500,003', valueOutput: 11500.003 },
26
+ { valueInput: '-R$100', valueOutput: -100 },
27
+ { valueInput: '-R$100,12', valueOutput: -100.12 },
28
+ { valueInput: '-R$11500,12', valueOutput: -11500.12 },
29
+ { valueInput: '-R$11500', valueOutput: -11500 },
30
+ { valueInput: '-R$11.500,003', valueOutput: -11500.003 },
31
+ { valueInput: '', valueOutput: NaN },
32
+ { valueInput: 'OrdinaryString', valueOutput: NaN },
33
+ { valueInput: '100.167.80', valueOutput: NaN },
34
+ { valueInput: 'uahsuhas,auhsuhasu', valueOutput: NaN },
35
+ { valueInput: '100,100,100', valueOutput: NaN },
36
+ { valueInput: 'OrdinaryString,.OrdinaryString', valueOutput: NaN },
37
+ { valueInput: 'OrdinaryString.,OrdinaryString', valueOutput: NaN },
38
+ { valueInput: '.121212', valueOutput: 0.121212 },
39
+ { valueInput: ',121212', valueOutput: 0.121212 },
40
+ { valueInput: '1,232,333.345', valueOutput: NaN },
41
+ { valueInput: '1232333,345', valueOutput: 1232333.345 },
42
+ ]
43
+
44
+ it('stringToNumber', function () {
45
+ let result: number;
46
+ arrayDataTest.forEach(e => {
47
+ result = NumberUtils.stringToNumber(e.valueInput);
48
+ expect(result).toBe(e.valueOutput);
49
+ })
50
+ });
51
+
52
+
53
+
54
+
55
+ // FORMAT
56
+ // ----------------------------------------------------------------------------------------
57
+
58
+
59
+ const casesStrValue = [
60
+
61
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
62
+ { precision: 2, prettyprecision: 1, strvalue: '1.000', strvalueOutPut: '1,0' },
63
+ { precision: 2, prettyprecision: 1, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
64
+ { precision: 4, prettyprecision: 2, strvalue: '1,232,333.345', strvalueOutPut: 'NaN' },
65
+ { precision: 2, prettyprecision: 1, strvalue: '1,23', strvalueOutPut: '1,23' },
66
+ { precision: 4, prettyprecision: 2, strvalue: '1.200.999', strvalueOutPut: 'NaN' },
67
+ { precision: 4, prettyprecision: 0, strvalue: '1200.00001', strvalueOutPut: '1.200' },
68
+ { precision: 4, prettyprecision: 0, strvalue: 'String', strvalueOutPut: 'NaN' },
69
+ { precision: 4, prettyprecision: 0, strvalue: '', strvalueOutPut: 'NaN' },
70
+
71
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999,3333', strvalueOutPut: '1.200.999,3333' },
72
+ { precision: 2, prettyprecision: undefined, strvalue: '1.000', strvalueOutPut: '1,00' },
73
+ { precision: 2, prettyprecision: undefined, strvalue: '1200999,99', strvalueOutPut: '1.200.999,99' },
74
+ { precision: 4, prettyprecision: undefined, strvalue: '1,232,333.345', strvalueOutPut: 'NaN' },
75
+ { precision: 2, prettyprecision: undefined, strvalue: '1,23', strvalueOutPut: '1,23' },
76
+ { precision: 4, prettyprecision: undefined, strvalue: '1.200.999', strvalueOutPut: 'NaN' },
77
+ { precision: 4, prettyprecision: undefined, strvalue: 'NaN', strvalueOutPut: 'NaN' },
78
+
79
+
80
+ { precision: 1, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,2' },
81
+ { precision: 1, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,1' },
82
+ { precision: 1, prettyprecision: 1.3, strvalue: '111,100', strvalueOutPut: '111,1' },
83
+ { precision: -1, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
84
+ { precision: -1, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
85
+ { precision: 1.2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
86
+
87
+
88
+ { precision: 2, prettyprecision: -1, strvalue: '111,199', strvalueOutPut: '111,20' },
89
+ { precision: 2, prettyprecision: -1, strvalue: '111,1000', strvalueOutPut: '111,10' },
90
+ { precision: -2, prettyprecision: 1, strvalue: '111,1009', strvalueOutPut: '111,1009' },
91
+ { precision: -2, prettyprecision: 1, strvalue: '111,1000', strvalueOutPut: '111,1' },
92
+
93
+
94
+ ];
95
+
96
+
97
+ it('format', function () {
98
+ let result: string = '';
99
+ casesStrValue.forEach(e => {
100
+ result = NumberUtils.format(e.strvalue, e.precision, e.prettyprecision);
101
+ expect(result).toBe(e.strvalueOutPut);
102
+ })
103
+
104
+ });
105
+
106
+
107
+
108
+
109
+ // keepOnlyDecimalSeparator
110
+ // ----------------------------------------------------------------------------------------
111
+ const testCasesTo_changeFormat = [
112
+
113
+ { inputValue: '1.200.999', outPutValue: '1,200,999' },
114
+ { inputValue: '1.000,99', outPutValue: '1,000.99' },
115
+ { inputValue: '1200999,99', outPutValue: '1200999.99' },
116
+ { inputValue: 'R$ 1,232,333.345', outPutValue: 'R$ 1.232.333,345' },
117
+ { inputValue: 'R$ 1.232.333,345', outPutValue: 'R$ 1,232,333.345' },
118
+
119
+ ]
120
+
121
+ it('format without formatnumber parameter', function () {
122
+ let result: string = '';
123
+ testCasesTo_changeFormat.forEach(e => {
124
+ result = NumberUtils.changeFormat(e.inputValue);
125
+ expect(result).toBe(e.outPutValue);
126
+ })
127
+
128
+ });
129
+
130
+
131
+ // keepOnlyDecimalSeparator
132
+ // ----------------------------------------------------------------------------------------
133
+ const testCasesTo_keepOnlyDecimalSeparator = [
134
+
135
+ { formatnumber: 'pt-BR', inputValue: '1.200.999', outPutValue: '1200999' },
136
+ { formatnumber: 'pt-BR', inputValue: '1000,99', outPutValue: '1000,99' },
137
+ { formatnumber: 'pt-BR', inputValue: '1200999,99', outPutValue: '1200999,99' },
138
+ { formatnumber: 'pt-BR', inputValue: 'R$ 1.232.333,345', outPutValue: 'R$ 1232333,345' },
139
+
140
+ { formatnumber: 'en-US', inputValue: '1,200,999', outPutValue: '1200999' },
141
+ { formatnumber: 'en-US', inputValue: '1,000.99', outPutValue: '1000.99' },
142
+ { formatnumber: 'en-US', inputValue: '1200999.99', outPutValue: '1200999.99' },
143
+ { formatnumber: 'en-US', inputValue: 'EUR 1,232,333.345', outPutValue: 'EUR 1232333.345' },
144
+
145
+
146
+ ]
147
+
148
+ it('format without formatnumber parameter', function () {
149
+ let result: string = '';
150
+ testCasesTo_keepOnlyDecimalSeparator.forEach(e => {
151
+ result = NumberUtils.keepOnlyDecimalSeparator(e.inputValue, e.formatnumber);
152
+ expect(result).toBe(e.outPutValue);
153
+ })
154
+
155
+ });
156
+
157
+
158
+ const testCasesTo_round = [
159
+ { decimal: undefined, inputValue: 100.12, outPutValue: 100.12 },
160
+ { decimal: 1, inputValue: 100.12, outPutValue: 100.1 },
161
+ { decimal: 2, inputValue: 100.12, outPutValue: 100.12 },
162
+ { decimal: 3, inputValue: 100.12, outPutValue: 100.12 },
163
+ { decimal: 1, inputValue: 100.15, outPutValue: 100.2 },
164
+ { decimal: 2, inputValue: 100.15, outPutValue: 100.15 },
165
+ { decimal: 3, inputValue: 100.15, outPutValue: 100.15 },
166
+ { decimal: 1, inputValue: 100.16, outPutValue: 100.2 },
167
+ { decimal: 2, inputValue: 100.16, outPutValue: 100.16 },
168
+ { decimal: 3, inputValue: 100.16, outPutValue: 100.16 },
169
+ { decimal: 12, inputValue: 2118000000000.0002, outPutValue: 2118000000000.0002 },
170
+ { decimal: 5, inputValue: 123.45, outPutValue: 123.45 },
171
+ { decimal: 0, inputValue: 123.45, outPutValue: 123 },
172
+ ]
173
+
174
+ it('format round number', function () {
175
+ let result: number;
176
+ testCasesTo_round.forEach(e => {
177
+ result = NumberUtils.round(e.inputValue, e.decimal);
178
+ expect(result).toBe(e.outPutValue);
179
+ })
180
+ });
181
+
182
+ });
@@ -0,0 +1,51 @@
1
+ import { StringUtils } from '../../src/utils/StringUtils';
2
+
3
+ describe('StringUtils', function () {
4
+
5
+ it('valor vazio', function () {
6
+ let result = StringUtils.isEmpty('');
7
+ expect(result).toBe(true);
8
+ });
9
+
10
+ it('valor em branco', function () {
11
+ let result = StringUtils.isEmpty(' ');
12
+ expect(result).toBe(true);
13
+ });
14
+
15
+ it('valor null', function () {
16
+ let result = StringUtils.isEmpty(null);
17
+ expect(result).toBe(true);
18
+ });
19
+
20
+ it('valor undefined', function () {
21
+ let result = StringUtils.isEmpty(undefined);
22
+ expect(result).toBe(true);
23
+ });
24
+
25
+ it('valor 0', function () {
26
+ let result = StringUtils.isEmpty('0');
27
+ expect(result).toBe(false);
28
+ });
29
+
30
+ it('com valor', function () {
31
+ let result = StringUtils.isEmpty('ab');
32
+ expect(result).toBe(false);
33
+ });
34
+
35
+ it('substitui vogais com acento por vogais sem acento', function () {
36
+
37
+ let resultadoInputMaiusculo = StringUtils.replaceAccentuatedChars('ÁÀÂÃÄ');
38
+ expect(resultadoInputMaiusculo).toBe('AAAAA');
39
+
40
+ let resultInputMinusculo = StringUtils.replaceAccentuatedChars('áàâãä');
41
+ expect(resultInputMinusculo).toBe('aaaaa');
42
+
43
+ let resultInputCedilhaMaiusculo = StringUtils.replaceAccentuatedChars('Ç');
44
+ expect(resultInputCedilhaMaiusculo).toBe('C');
45
+
46
+ let resultInputCedilhaMinusculo = StringUtils.replaceAccentuatedChars('ç');
47
+ expect(resultInputCedilhaMinusculo).toBe('c');
48
+
49
+ });
50
+
51
+ });
@@ -0,0 +1,26 @@
1
+ import { TimeFormatter } from '../../src/utils/TimeFormatter';
2
+
3
+ describe('TimeFormatter', function () {
4
+ it("Case: input string unformated with showSeconds", function () {
5
+ let value = TimeFormatter.prepareValue("1110", false);
6
+ expect(value).toEqual("11:10");
7
+ });
8
+
9
+ it("Case: input string unformated without showSeconds", function () {
10
+ let value = TimeFormatter.prepareValue("1110", true);
11
+ expect(value).toEqual("00:11:10");
12
+ });
13
+
14
+
15
+ it("Case: validateTime", function () {
16
+ let isValid = TimeFormatter.validateTime("2525", false);
17
+ expect(isValid).toEqual(false);
18
+ isValid = TimeFormatter.validateTime("2525", true);
19
+ expect(isValid).toEqual(false);
20
+ isValid = TimeFormatter.validateTime("232920", true);
21
+ expect(isValid).toEqual(true);
22
+ isValid = TimeFormatter.validateTime("232920", false);
23
+ expect(isValid).toEqual(true);
24
+ });
25
+
26
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "lib": ["ESNext", "DOM"],
5
+ "sourceMap": true,
6
+ "outDir": "dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "moduleResolution": "node",
10
+ "declaration": true,
11
+ },
12
+ "removeComments": true,
13
+ "preserveConstEnums": true,
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules", "**/*.spec.ts"]
16
+ }