@sera4/essentia 1.1.65 → 1.1.66-rc.1

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 (245) hide show
  1. package/coverage/base.css +224 -0
  2. package/coverage/block-navigation.js +87 -0
  3. package/coverage/configurations/index.html +116 -0
  4. package/coverage/configurations/server-config.ts.html +94 -0
  5. package/coverage/dns/DnsCache.ts.html +598 -0
  6. package/coverage/dns/index.html +131 -0
  7. package/coverage/dns/index.ts.html +94 -0
  8. package/coverage/favicon.png +0 -0
  9. package/coverage/health/index.html +116 -0
  10. package/coverage/health/index.ts.html +778 -0
  11. package/coverage/index.html +161 -0
  12. package/coverage/lcov-report/base.css +224 -0
  13. package/coverage/lcov-report/block-navigation.js +87 -0
  14. package/coverage/lcov-report/configurations/index.html +116 -0
  15. package/coverage/lcov-report/configurations/server-config.ts.html +94 -0
  16. package/coverage/lcov-report/dns/DnsCache.ts.html +598 -0
  17. package/coverage/lcov-report/dns/index.html +131 -0
  18. package/coverage/lcov-report/dns/index.ts.html +94 -0
  19. package/coverage/lcov-report/favicon.png +0 -0
  20. package/coverage/lcov-report/health/index.html +116 -0
  21. package/coverage/lcov-report/health/index.ts.html +778 -0
  22. package/coverage/lcov-report/index.html +161 -0
  23. package/coverage/lcov-report/logger/index.html +131 -0
  24. package/coverage/lcov-report/logger/index.ts.html +94 -0
  25. package/coverage/lcov-report/logger/s4-logger.ts.html +514 -0
  26. package/coverage/lcov-report/prettify.css +1 -0
  27. package/coverage/lcov-report/prettify.js +2 -0
  28. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  29. package/coverage/lcov-report/sorter.js +196 -0
  30. package/coverage/lcov.info +747 -0
  31. package/coverage/logger/index.html +131 -0
  32. package/coverage/logger/index.ts.html +94 -0
  33. package/coverage/logger/s4-logger.ts.html +514 -0
  34. package/coverage/prettify.css +1 -0
  35. package/coverage/prettify.js +2 -0
  36. package/coverage/sort-arrow-sprite.png +0 -0
  37. package/coverage/sorter.js +196 -0
  38. package/coverage/tmp/coverage-24302-1746472691313-0.json +1 -0
  39. package/coverage/tmp/coverage-24302-1746472691366-1.json +1 -0
  40. package/dist/cache/index.d.ts +22 -0
  41. package/dist/cache/index.js +166 -0
  42. package/dist/cache/index.js.map +1 -0
  43. package/dist/constants/index.d.ts +6 -0
  44. package/dist/constants/index.js +9 -0
  45. package/dist/constants/index.js.map +1 -0
  46. package/dist/coverage/block-navigation.d.ts +1 -0
  47. package/dist/coverage/block-navigation.js +70 -0
  48. package/dist/coverage/block-navigation.js.map +1 -0
  49. package/dist/coverage/lcov-report/block-navigation.d.ts +1 -0
  50. package/dist/coverage/lcov-report/block-navigation.js +70 -0
  51. package/dist/coverage/lcov-report/block-navigation.js.map +1 -0
  52. package/dist/coverage/lcov-report/prettify.d.ts +0 -0
  53. package/dist/coverage/lcov-report/prettify.js +477 -0
  54. package/dist/coverage/lcov-report/prettify.js.map +1 -0
  55. package/dist/coverage/lcov-report/sorter.d.ts +1 -0
  56. package/dist/coverage/lcov-report/sorter.js +163 -0
  57. package/dist/coverage/lcov-report/sorter.js.map +1 -0
  58. package/dist/coverage/prettify.d.ts +0 -0
  59. package/dist/coverage/prettify.js +477 -0
  60. package/dist/coverage/prettify.js.map +1 -0
  61. package/dist/coverage/sorter.d.ts +1 -0
  62. package/dist/coverage/sorter.js +163 -0
  63. package/dist/coverage/sorter.js.map +1 -0
  64. package/dist/formatter/index.d.ts +37 -0
  65. package/dist/formatter/index.js +75 -0
  66. package/dist/formatter/index.js.map +1 -0
  67. package/dist/hal/index.d.ts +5 -0
  68. package/dist/hal/index.js +69 -0
  69. package/dist/hal/index.js.map +1 -0
  70. package/dist/health/health-logger.d.ts +9 -0
  71. package/dist/health/health-logger.js +34 -0
  72. package/dist/health/health-logger.js.map +1 -0
  73. package/dist/health/index.d.ts +19 -0
  74. package/dist/health/index.js +175 -0
  75. package/dist/health/index.js.map +1 -0
  76. package/dist/helpers/index.d.ts +1 -0
  77. package/dist/helpers/index.js +2 -0
  78. package/dist/helpers/index.js.map +1 -0
  79. package/dist/helpers/test-server-wrapper.d.ts +120 -0
  80. package/dist/helpers/test-server-wrapper.js +165 -0
  81. package/dist/helpers/test-server-wrapper.js.map +1 -0
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.js +17 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/last-commit.d.ts +1 -0
  86. package/dist/last-commit.js +12 -0
  87. package/dist/last-commit.js.map +1 -0
  88. package/dist/last_commit/index.d.ts +7 -0
  89. package/dist/last_commit/index.js +83 -0
  90. package/dist/last_commit/index.js.map +1 -0
  91. package/dist/paginator/s4-pagination.d.ts +9 -0
  92. package/dist/paginator/s4-pagination.js +49 -0
  93. package/dist/paginator/s4-pagination.js.map +1 -0
  94. package/dist/paginator/sql-pagination.d.ts +27 -0
  95. package/dist/paginator/sql-pagination.js +166 -0
  96. package/dist/paginator/sql-pagination.js.map +1 -0
  97. package/dist/paper-trail/helpers.d.ts +11 -0
  98. package/dist/paper-trail/helpers.js +74 -0
  99. package/dist/paper-trail/helpers.js.map +1 -0
  100. package/dist/paper-trail/index.d.ts +13 -0
  101. package/dist/paper-trail/index.js +662 -0
  102. package/dist/paper-trail/index.js.map +1 -0
  103. package/dist/prompts/index.d.ts +14 -0
  104. package/dist/prompts/index.js +63 -0
  105. package/dist/prompts/index.js.map +1 -0
  106. package/dist/queue/index.d.ts +166 -0
  107. package/dist/queue/index.js +371 -0
  108. package/dist/queue/index.js.map +1 -0
  109. package/dist/queue/publisher.d.ts +31 -0
  110. package/dist/queue/publisher.js +84 -0
  111. package/dist/queue/publisher.js.map +1 -0
  112. package/dist/queue/queue-logger.d.ts +9 -0
  113. package/dist/queue/queue-logger.js +35 -0
  114. package/dist/queue/queue-logger.js.map +1 -0
  115. package/dist/queue/subscriber.d.ts +39 -0
  116. package/dist/queue/subscriber.js +97 -0
  117. package/dist/queue/subscriber.js.map +1 -0
  118. package/dist/safe_proxy/index.d.ts +13 -0
  119. package/dist/safe_proxy/index.js +54 -0
  120. package/dist/safe_proxy/index.js.map +1 -0
  121. package/dist/serializer/index.d.ts +5 -0
  122. package/dist/serializer/index.js +83 -0
  123. package/dist/serializer/index.js.map +1 -0
  124. package/dist/test/debug-array.d.ts +0 -0
  125. package/dist/test/debug-array.js +1 -0
  126. package/dist/test/debug-array.js.map +1 -0
  127. package/dist/test/debug-setJSONB.d.ts +0 -0
  128. package/dist/test/debug-setJSONB.js +1 -0
  129. package/dist/test/debug-setJSONB.js.map +1 -0
  130. package/dist/test/prompt.test.d.ts +1 -0
  131. package/dist/test/prompt.test.js +74 -0
  132. package/dist/test/prompt.test.js.map +1 -0
  133. package/dist/test/s4-formatter.spec.d.ts +1 -0
  134. package/dist/test/s4-formatter.spec.js +67 -0
  135. package/dist/test/s4-formatter.spec.js.map +1 -0
  136. package/dist/test/s4-pagination.spec.d.ts +1 -0
  137. package/dist/test/s4-pagination.spec.js +170 -0
  138. package/dist/test/s4-pagination.spec.js.map +1 -0
  139. package/dist/test/safe-proxy.spec.d.ts +1 -0
  140. package/dist/test/safe-proxy.spec.js +252 -0
  141. package/dist/test/safe-proxy.spec.js.map +1 -0
  142. package/dist/test/serializer.spec.d.ts +1 -0
  143. package/dist/test/serializer.spec.js +27 -0
  144. package/dist/test/serializer.spec.js.map +1 -0
  145. package/dist/test/utils.spec.d.ts +1 -0
  146. package/dist/test/utils.spec.js +446 -0
  147. package/dist/test/utils.spec.js.map +1 -0
  148. package/dist/ts/cache/index.d.ts +33 -0
  149. package/dist/ts/cache/index.js +171 -0
  150. package/dist/ts/cache/index.js.map +1 -0
  151. package/dist/ts/configurations/server-config.d.ts +4 -0
  152. package/dist/ts/configurations/server-config.js +2 -0
  153. package/dist/ts/configurations/server-config.js.map +1 -0
  154. package/dist/ts/constants/index.d.ts +7 -0
  155. package/dist/ts/constants/index.js +8 -0
  156. package/dist/ts/constants/index.js.map +1 -0
  157. package/dist/ts/cycle/index.d.ts +53 -0
  158. package/dist/ts/cycle/index.js +169 -0
  159. package/dist/ts/cycle/index.js.map +1 -0
  160. package/dist/ts/dns/DnsCache.d.ts +50 -0
  161. package/dist/ts/dns/DnsCache.js +137 -0
  162. package/dist/ts/dns/DnsCache.js.map +1 -0
  163. package/dist/ts/dns/index.d.ts +4 -0
  164. package/dist/ts/dns/index.js +4 -0
  165. package/dist/ts/dns/index.js.map +1 -0
  166. package/dist/ts/formatter/index.d.ts +44 -0
  167. package/dist/ts/formatter/index.js +76 -0
  168. package/dist/ts/formatter/index.js.map +1 -0
  169. package/dist/ts/hal/index.d.ts +26 -0
  170. package/dist/ts/hal/index.js +70 -0
  171. package/dist/ts/hal/index.js.map +1 -0
  172. package/dist/ts/health/index.d.ts +53 -0
  173. package/dist/ts/health/index.js +165 -0
  174. package/dist/ts/health/index.js.map +1 -0
  175. package/dist/ts/helpers/index.d.ts +1 -0
  176. package/dist/ts/helpers/index.js +2 -0
  177. package/dist/ts/helpers/index.js.map +1 -0
  178. package/dist/ts/helpers/test-server-wrapper.d.ts +56 -0
  179. package/dist/ts/helpers/test-server-wrapper.js +144 -0
  180. package/dist/ts/helpers/test-server-wrapper.js.map +1 -0
  181. package/dist/ts/index.d.ts +22 -0
  182. package/dist/ts/index.js +27 -0
  183. package/dist/ts/index.js.map +1 -0
  184. package/dist/ts/last-commit/index.d.ts +12 -0
  185. package/dist/ts/last-commit/index.js +82 -0
  186. package/dist/ts/last-commit/index.js.map +1 -0
  187. package/dist/ts/logger/index.d.ts +3 -0
  188. package/dist/ts/logger/index.js +4 -0
  189. package/dist/ts/logger/index.js.map +1 -0
  190. package/dist/ts/logger/s4-logger.d.ts +23 -0
  191. package/dist/ts/logger/s4-logger.js +105 -0
  192. package/dist/ts/logger/s4-logger.js.map +1 -0
  193. package/dist/ts/paginator/index.d.ts +2 -0
  194. package/dist/ts/paginator/index.js +3 -0
  195. package/dist/ts/paginator/index.js.map +1 -0
  196. package/dist/ts/paginator/s4-pagination.d.ts +26 -0
  197. package/dist/ts/paginator/s4-pagination.js +49 -0
  198. package/dist/ts/paginator/s4-pagination.js.map +1 -0
  199. package/dist/ts/paginator/sql-pagination.d.ts +52 -0
  200. package/dist/ts/paginator/sql-pagination.js +157 -0
  201. package/dist/ts/paginator/sql-pagination.js.map +1 -0
  202. package/dist/ts/paper-trail/helpers.d.ts +14 -0
  203. package/dist/ts/paper-trail/helpers.js +74 -0
  204. package/dist/ts/paper-trail/helpers.js.map +1 -0
  205. package/dist/ts/paper-trail/index.d.ts +54 -0
  206. package/dist/ts/paper-trail/index.js +236 -0
  207. package/dist/ts/paper-trail/index.js.map +1 -0
  208. package/dist/ts/prompts/index.d.ts +21 -0
  209. package/dist/ts/prompts/index.js +68 -0
  210. package/dist/ts/prompts/index.js.map +1 -0
  211. package/dist/ts/queue/index.d.ts +232 -0
  212. package/dist/ts/queue/index.js +440 -0
  213. package/dist/ts/queue/index.js.map +1 -0
  214. package/dist/ts/queue/publisher.d.ts +41 -0
  215. package/dist/ts/queue/publisher.js +84 -0
  216. package/dist/ts/queue/publisher.js.map +1 -0
  217. package/dist/ts/queue/queue-logger.d.ts +10 -0
  218. package/dist/ts/queue/queue-logger.js +35 -0
  219. package/dist/ts/queue/queue-logger.js.map +1 -0
  220. package/dist/ts/queue/subscriber.d.ts +55 -0
  221. package/dist/ts/queue/subscriber.js +98 -0
  222. package/dist/ts/queue/subscriber.js.map +1 -0
  223. package/dist/ts/safe-proxy/index.d.ts +35 -0
  224. package/dist/ts/safe-proxy/index.js +54 -0
  225. package/dist/ts/safe-proxy/index.js.map +1 -0
  226. package/dist/ts/serializer/index.d.ts +52 -0
  227. package/dist/ts/serializer/index.js +83 -0
  228. package/dist/ts/serializer/index.js.map +1 -0
  229. package/dist/ts/task-scheduler/index.d.ts +130 -0
  230. package/dist/ts/task-scheduler/index.js +259 -0
  231. package/dist/ts/task-scheduler/index.js.map +1 -0
  232. package/dist/ts/utils/index.d.ts +49 -0
  233. package/dist/ts/utils/index.js +157 -0
  234. package/dist/ts/utils/index.js.map +1 -0
  235. package/package.json +10 -8
  236. package/paper-trail/index.js +2 -1
  237. package/queue/index.js +57 -69
  238. package/scripts/publish.sh +46 -0
  239. package/test/health.spec.js +213 -0
  240. package/test/prompt.test.js +91 -0
  241. package/test/s4-formatter.spec.js +80 -0
  242. package/test/s4-pagination.spec.js +196 -0
  243. package/test/serializer.spec.js +34 -0
  244. package/test/utils.spec.js +145 -0
  245. package/package.tar.gz +0 -0
@@ -0,0 +1,196 @@
1
+ import should from "should";
2
+ import S4Pagination from "../paginator/s4-pagination.js";
3
+ import http_mocks from "node-mocks-http";
4
+ import events from "events";
5
+
6
+ describe("Pagination", function () {
7
+ var paginator = null;
8
+ var request = null;
9
+ var response = null;
10
+ var next = null;
11
+
12
+ before("Setup", function () {
13
+ next = function () { };
14
+ response = http_mocks.createResponse({ eventEmitter: events.EventEmitter });
15
+ request = http_mocks.createRequest({
16
+ method: "GET",
17
+ url: "/"
18
+ })
19
+ paginator = S4Pagination.createPaginator(request, response, next);
20
+ });
21
+
22
+ describe("Parsing query parameters", function () {
23
+ describe("Default values", function () {
24
+ it("should have default page set to 1", function () {
25
+ paginator.should.have.property("page", 1);
26
+ });
27
+
28
+ it("should have default page size set to 5", function () {
29
+ paginator.should.have.property("page_size", 5);
30
+ });
31
+ });
32
+
33
+ describe("Page value set to 0", function () {
34
+ before("Setup", function () {
35
+ request = http_mocks.createRequest({
36
+ method: "GET",
37
+ url: "/?page=0"
38
+ })
39
+ paginator = S4Pagination.createPaginator(request, response, next);
40
+ });
41
+
42
+ it("should set page to 1", function () {
43
+ paginator.should.have.property("page", 1);
44
+ });
45
+ });
46
+
47
+ describe("Page value set to negative", function () {
48
+ before("Setup", function () {
49
+ request = http_mocks.createRequest({
50
+ method: "GET",
51
+ url: "/?page=-1"
52
+ })
53
+ paginator = S4Pagination.createPaginator(request, response, next);
54
+ });
55
+
56
+ it("should set page to 1", function () {
57
+ paginator.should.have.property("page", 1);
58
+ });
59
+ });
60
+
61
+ describe("Page value set to 2", function () {
62
+ before("Setup", function () {
63
+ request = http_mocks.createRequest({
64
+ method: "GET",
65
+ url: "/?page=2"
66
+ })
67
+ paginator = S4Pagination.createPaginator(request, response, next);
68
+ });
69
+
70
+ it("should set page to 2", function () {
71
+ paginator.should.have.property("page", 2);
72
+ });
73
+ });
74
+
75
+ describe("Page value set to 10", function () {
76
+ before("Setup", function () {
77
+ request = http_mocks.createRequest({
78
+ method: "GET",
79
+ url: "/?page=10"
80
+ })
81
+ paginator = S4Pagination.createPaginator(request, response, next);
82
+ });
83
+
84
+ it("should set page to 10", function () {
85
+ paginator.should.have.property("page", 10);
86
+ });
87
+ });
88
+
89
+ describe("Page value set to 100", function () {
90
+ before("Setup", function () {
91
+ request = http_mocks.createRequest({
92
+ method: "GET",
93
+ url: "/?page=100"
94
+ })
95
+ paginator = S4Pagination.createPaginator(request, response, next);
96
+ });
97
+
98
+ it("should set page to 100", function () {
99
+ paginator.should.have.property("page", 100);
100
+ });
101
+ });
102
+
103
+ describe("Page Size value set to 0", function () {
104
+ before("Setup", function () {
105
+ request = http_mocks.createRequest({
106
+ method: "GET",
107
+ url: "/?page_size=0"
108
+ })
109
+ paginator = S4Pagination.createPaginator(request, response, next);
110
+ });
111
+
112
+ it("should set page size to 5", function () {
113
+ paginator.should.have.property("page_size", 5);
114
+ });
115
+ });
116
+
117
+ describe("Page Size value set to negative", function () {
118
+ before("Setup", function () {
119
+ request = http_mocks.createRequest({
120
+ method: "GET",
121
+ url: "/?page_size=-1"
122
+ })
123
+ paginator = S4Pagination.createPaginator(request, response, next);
124
+ });
125
+
126
+ it("should set page size to 5", function () {
127
+ paginator.should.have.property("page_size", 5);
128
+ });
129
+ });
130
+
131
+ describe("Page Size value set to 2", function () {
132
+ before("Setup", function () {
133
+ request = http_mocks.createRequest({
134
+ method: "GET",
135
+ url: "/?page_size=2"
136
+ })
137
+ paginator = S4Pagination.createPaginator(request, response, next);
138
+ });
139
+
140
+ it("should set page size to 5", function () {
141
+ paginator.should.have.property("page_size", 5);
142
+ });
143
+ });
144
+
145
+ describe("Page Size value set to 10", function () {
146
+ before("Setup", function () {
147
+ request = http_mocks.createRequest({
148
+ method: "GET",
149
+ url: "/?page_size=10"
150
+ })
151
+ paginator = S4Pagination.createPaginator(request, response, next);
152
+ });
153
+
154
+ it("should set page size to 10", function () {
155
+ paginator.should.have.property("page_size", 10);
156
+ });
157
+ });
158
+
159
+ describe("Page Size value set to 100", function () {
160
+ before("Setup", function () {
161
+ request = http_mocks.createRequest({
162
+ method: "GET",
163
+ url: "/?page_size=100"
164
+ })
165
+ paginator = S4Pagination.createPaginator(request, response, next);
166
+ });
167
+
168
+ it("should set page size to 100", function () {
169
+ paginator.should.have.property("page_size", 100);
170
+ });
171
+ });
172
+ });
173
+
174
+ describe("Replying", function() {
175
+ beforeEach("Clear request", function() {
176
+ response = http_mocks.createResponse({ eventEmitter: events.EventEmitter });
177
+ paginator = S4Pagination.createPaginator(request, response, next);
178
+ });
179
+
180
+ it ("should return 500 if data is null", function(){
181
+ paginator.reply(null);
182
+ response.statusCode.should.equal(500);
183
+ });
184
+
185
+ it ("should return pagination data", function(){
186
+ const items = [1,2,3,4,5,6,7,8,9,10];
187
+ const data = {
188
+ docs : items,
189
+ total : items.length,
190
+ };
191
+ paginator.reply(data);
192
+ response.statusCode.should.equal(200);
193
+ response._getHeaders().should.have.property("s4-pagination");
194
+ });
195
+ });
196
+ });
@@ -0,0 +1,34 @@
1
+ import { expect } from "chai";
2
+ import serializer from "../serializer/index.js";
3
+
4
+ describe("Serializer", () => {
5
+
6
+ describe("Serialize", () => {
7
+
8
+ it ("should not show Hidden/Removed fields", () => {
9
+ const model = { prototype: {} }
10
+ model.prototype.get = function() {
11
+ return {
12
+ name: "John",
13
+ hidden_prefs: "should be hidden",
14
+ password: "password",
15
+ password_salt: "password_salt",
16
+ mfa_totp_secret: "mfa_totp_secret",
17
+ }
18
+ }
19
+ const options = { hide: ["hidden_prefs"], remove: ["password", "password_salt", "mfa_totp_secret"] }
20
+
21
+ serializer.serialize(model, options);
22
+
23
+ const serialized = model.prototype.toJSON();
24
+
25
+ expect(serialized.name).to.eq("John");
26
+
27
+ expect(serialized.hidden_prefs).to.be.undefined;
28
+ expect(serialized.password).to.be.undefined;
29
+ expect(serialized.password_salt).to.be.undefined;
30
+ expect(serialized.mfa_totp_secret).to.be.undefined;
31
+ });
32
+
33
+ });
34
+ });
@@ -0,0 +1,145 @@
1
+ import { expect } from "chai";
2
+
3
+ import { utils } from "../utils/index.js";
4
+ import { TWS_ROUTE_TYPES } from "../constants/index.js";
5
+
6
+ describe("Utils", () => {
7
+
8
+ describe("UUID V4", () => {
9
+
10
+ it ("should not validate ABCD", () => {
11
+ expect(utils.isValidUuidV4("ABC")).to.be.false
12
+ });
13
+
14
+ it ("should not validate null", () => {
15
+ expect(utils.isValidUuidV4(null)).to.be.false
16
+ });
17
+
18
+ it ("should not validate undefined", () => {
19
+ expect(utils.isValidUuidV4()).to.be.false
20
+ });
21
+
22
+ it ("should not validate empty string", () => {
23
+ expect(utils.isValidUuidV4("")).to.be.false
24
+ });
25
+
26
+ it ("should not validate 26d61a823587-4875-98a8e950e1bf2350", () => {
27
+ expect(utils.isValidUuidV4("26d61a823587-4875-98a8-950e1bf2350")).to.be.false
28
+ });
29
+
30
+ it ("should not validate 26d61a82-3587-4875-98a8-e950e1bf235", () => {
31
+ expect(utils.isValidUuidV4("26d61a82-3587-4875-98a8-e950e1bf235")).to.be.false
32
+ });
33
+
34
+ it ("should not validate 26d61a8-3587-4875-98a8-e950e1bf2350", () => {
35
+ expect(utils.isValidUuidV4("26d61a8-3587-4875-98a8-e950e1bf2350")).to.be.false
36
+ });
37
+
38
+ it ("should not validate 26d61a82-3587-487-98a8-e950e1bf2350", () => {
39
+ expect(utils.isValidUuidV4("26d61a82-3587-487-98a8-e950e1bf2350")).to.be.false
40
+ });
41
+
42
+ it ("should validate 26d61a82-3587-4875-98a8-e950e1bf2350", () => {
43
+ expect(utils.isValidUuidV4("26d61a82-3587-4875-98a8-e950e1bf2350")).to.be.true
44
+ });
45
+
46
+ it ("should validate 26D61A82-3587-4875-98A8-E950E1BF2350", () => {
47
+ expect(utils.isValidUuidV4("26D61A82-3587-4875-98A8-E950E1BF2350")).to.be.true
48
+ });
49
+
50
+ });
51
+
52
+ describe("String -> Integer Array", () => {
53
+ it ("Should return [] with a null/undefined input", () => {
54
+ expect(utils.convertToIntegerArray()).to.be.an('array').that.is.empty;
55
+ });
56
+
57
+ it ("Should return a valid integer array for '1,2,3'", () => {
58
+ expect(utils.convertToIntegerArray('1,2,3')).to.be.an('array').to.deep.equal([1, 2, 3])
59
+ });
60
+
61
+ it ("Should return a valid integer array for '[1,2,3]'", () => {
62
+ expect(utils.convertToIntegerArray('[1,2,3]')).to.be.an('array').to.deep.equal([1, 2, 3])
63
+ });
64
+
65
+ it ("Should return a valid integer array for '[1,2],3'", () => {
66
+ expect(utils.convertToIntegerArray('[1,2],3')).to.be.an('array').to.deep.equal([1, 2])
67
+ });
68
+
69
+ it ("Should return a valid integer array for '[1,2]],3'", () => {
70
+ expect(utils.convertToIntegerArray('[1,2]],3')).to.be.an('array').to.deep.equal([1, 2])
71
+ });
72
+
73
+ it ("Should return a valid integer array for '[1,2,3'", () => {
74
+ expect(utils.convertToIntegerArray('[1,2,3')).to.be.an('array').to.deep.equal([1, 2, 3])
75
+ });
76
+
77
+ it ("Should return a valid integer array for '1[1,2],3'", () => {
78
+ expect(utils.convertToIntegerArray('1[1,2],3')).to.be.an('array').to.deep.equal([1, 2])
79
+ });
80
+
81
+ it ("Should return a valid integer array for 1", () => {
82
+ expect(utils.convertToIntegerArray(1)).to.be.an('array').to.deep.equal([1])
83
+ });
84
+
85
+ it ("Should return a valid integer array for '1'", () => {
86
+ expect(utils.convertToIntegerArray('1')).to.be.an('array').to.deep.equal([1])
87
+ });
88
+
89
+ it ("Should return a valid integer array for '1w'", () => {
90
+ expect(utils.convertToIntegerArray('1w')).to.be.an('array').to.deep.equal([1])
91
+ });
92
+
93
+ it ("Should return a valid integer array for '[1,2e'", () => {
94
+ expect(utils.convertToIntegerArray('[1,2e')).to.be.an('array').to.deep.equal([1,2])
95
+ });
96
+ });
97
+
98
+ describe("Route testing", () => {
99
+ it ("Return -1 for a blank domain", () => {
100
+ expect(utils.getRouteType('')).to.eq(-1);
101
+ });
102
+ it ("Return a web route type for tws-web", () => {
103
+ const route = utils.getRouteType('tws-web.sera4.com/v3/xxx');
104
+ expect(route).to.eq(TWS_ROUTE_TYPES['web']);
105
+ expect(utils.isWebRoute(route)).to.be.true
106
+ });
107
+ it ("Return a web route type for tws-web-staging", () => {
108
+ const route = utils.getRouteType('tws-web-environmentX.sera4.com/v3/xxx');
109
+ expect(route).to.eq(TWS_ROUTE_TYPES['web']);
110
+ expect(utils.isWebRoute(route)).to.be.true
111
+ });
112
+ it ("Return a mobile route type for tws-mob", () => {
113
+ const route = utils.getRouteType('tws-mob.sera4.com/v3/xxx');
114
+ expect(route).to.eq(TWS_ROUTE_TYPES['mobile']);
115
+ expect(utils.isMobileRoute(route)).to.be.true
116
+ });
117
+ it ("Return a mobile route type for tws-mob-staging", () => {
118
+ const route = utils.getRouteType('tws-mob-environmentX.sera4.com/v3/xxx');
119
+ expect(route).to.eq(TWS_ROUTE_TYPES['mobile']);
120
+ expect(utils.isMobileRoute(route)).to.be.true
121
+ });
122
+ it ("Return an API route type for tws-api-xxxx", () => {
123
+ const route = utils.getRouteType('tws-api-1234.sera4.com/v3/xxx');
124
+ expect(route).to.eq(TWS_ROUTE_TYPES['api']);
125
+ expect(utils.isApiRoute(route)).to.be.true
126
+ });
127
+ it ("Return isWebRoute TRUE for 1 or '1'", () => {
128
+ expect(utils.isWebRoute(1)).to.eq(true);
129
+ expect(utils.isWebRoute('1')).to.eq(true);
130
+ });
131
+ it ("Return isMobileRoute TRUE for 2 or '2'", () => {
132
+ expect(utils.isMobileRoute(2)).to.eq(true);
133
+ expect(utils.isMobileRoute('2')).to.eq(true);
134
+ });
135
+ it ("Return isApiRoute TRUE for 3 or '3'", () => {
136
+ expect(utils.isApiRoute(3)).to.eq(true);
137
+ expect(utils.isApiRoute('3')).to.eq(true);
138
+ });
139
+ it ("Return isApiRoute TRUE for many other values", () => {
140
+ expect(utils.isOtherRoute(4)).to.eq(true);
141
+ expect(utils.isOtherRoute('4')).to.eq(true);
142
+ expect(utils.isOtherRoute('a')).to.eq(true);
143
+ });
144
+ });
145
+ });
package/package.tar.gz DELETED
Binary file