@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.
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/configurations/index.html +116 -0
- package/coverage/configurations/server-config.ts.html +94 -0
- package/coverage/dns/DnsCache.ts.html +598 -0
- package/coverage/dns/index.html +131 -0
- package/coverage/dns/index.ts.html +94 -0
- package/coverage/favicon.png +0 -0
- package/coverage/health/index.html +116 -0
- package/coverage/health/index.ts.html +778 -0
- package/coverage/index.html +161 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/configurations/index.html +116 -0
- package/coverage/lcov-report/configurations/server-config.ts.html +94 -0
- package/coverage/lcov-report/dns/DnsCache.ts.html +598 -0
- package/coverage/lcov-report/dns/index.html +131 -0
- package/coverage/lcov-report/dns/index.ts.html +94 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/health/index.html +116 -0
- package/coverage/lcov-report/health/index.ts.html +778 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/logger/index.html +131 -0
- package/coverage/lcov-report/logger/index.ts.html +94 -0
- package/coverage/lcov-report/logger/s4-logger.ts.html +514 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +747 -0
- package/coverage/logger/index.html +131 -0
- package/coverage/logger/index.ts.html +94 -0
- package/coverage/logger/s4-logger.ts.html +514 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/tmp/coverage-24302-1746472691313-0.json +1 -0
- package/coverage/tmp/coverage-24302-1746472691366-1.json +1 -0
- package/dist/cache/index.d.ts +22 -0
- package/dist/cache/index.js +166 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +9 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/coverage/block-navigation.d.ts +1 -0
- package/dist/coverage/block-navigation.js +70 -0
- package/dist/coverage/block-navigation.js.map +1 -0
- package/dist/coverage/lcov-report/block-navigation.d.ts +1 -0
- package/dist/coverage/lcov-report/block-navigation.js +70 -0
- package/dist/coverage/lcov-report/block-navigation.js.map +1 -0
- package/dist/coverage/lcov-report/prettify.d.ts +0 -0
- package/dist/coverage/lcov-report/prettify.js +477 -0
- package/dist/coverage/lcov-report/prettify.js.map +1 -0
- package/dist/coverage/lcov-report/sorter.d.ts +1 -0
- package/dist/coverage/lcov-report/sorter.js +163 -0
- package/dist/coverage/lcov-report/sorter.js.map +1 -0
- package/dist/coverage/prettify.d.ts +0 -0
- package/dist/coverage/prettify.js +477 -0
- package/dist/coverage/prettify.js.map +1 -0
- package/dist/coverage/sorter.d.ts +1 -0
- package/dist/coverage/sorter.js +163 -0
- package/dist/coverage/sorter.js.map +1 -0
- package/dist/formatter/index.d.ts +37 -0
- package/dist/formatter/index.js +75 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/hal/index.d.ts +5 -0
- package/dist/hal/index.js +69 -0
- package/dist/hal/index.js.map +1 -0
- package/dist/health/health-logger.d.ts +9 -0
- package/dist/health/health-logger.js +34 -0
- package/dist/health/health-logger.js.map +1 -0
- package/dist/health/index.d.ts +19 -0
- package/dist/health/index.js +175 -0
- package/dist/health/index.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/test-server-wrapper.d.ts +120 -0
- package/dist/helpers/test-server-wrapper.js +165 -0
- package/dist/helpers/test-server-wrapper.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/last-commit.d.ts +1 -0
- package/dist/last-commit.js +12 -0
- package/dist/last-commit.js.map +1 -0
- package/dist/last_commit/index.d.ts +7 -0
- package/dist/last_commit/index.js +83 -0
- package/dist/last_commit/index.js.map +1 -0
- package/dist/paginator/s4-pagination.d.ts +9 -0
- package/dist/paginator/s4-pagination.js +49 -0
- package/dist/paginator/s4-pagination.js.map +1 -0
- package/dist/paginator/sql-pagination.d.ts +27 -0
- package/dist/paginator/sql-pagination.js +166 -0
- package/dist/paginator/sql-pagination.js.map +1 -0
- package/dist/paper-trail/helpers.d.ts +11 -0
- package/dist/paper-trail/helpers.js +74 -0
- package/dist/paper-trail/helpers.js.map +1 -0
- package/dist/paper-trail/index.d.ts +13 -0
- package/dist/paper-trail/index.js +662 -0
- package/dist/paper-trail/index.js.map +1 -0
- package/dist/prompts/index.d.ts +14 -0
- package/dist/prompts/index.js +63 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/queue/index.d.ts +166 -0
- package/dist/queue/index.js +371 -0
- package/dist/queue/index.js.map +1 -0
- package/dist/queue/publisher.d.ts +31 -0
- package/dist/queue/publisher.js +84 -0
- package/dist/queue/publisher.js.map +1 -0
- package/dist/queue/queue-logger.d.ts +9 -0
- package/dist/queue/queue-logger.js +35 -0
- package/dist/queue/queue-logger.js.map +1 -0
- package/dist/queue/subscriber.d.ts +39 -0
- package/dist/queue/subscriber.js +97 -0
- package/dist/queue/subscriber.js.map +1 -0
- package/dist/safe_proxy/index.d.ts +13 -0
- package/dist/safe_proxy/index.js +54 -0
- package/dist/safe_proxy/index.js.map +1 -0
- package/dist/serializer/index.d.ts +5 -0
- package/dist/serializer/index.js +83 -0
- package/dist/serializer/index.js.map +1 -0
- package/dist/test/debug-array.d.ts +0 -0
- package/dist/test/debug-array.js +1 -0
- package/dist/test/debug-array.js.map +1 -0
- package/dist/test/debug-setJSONB.d.ts +0 -0
- package/dist/test/debug-setJSONB.js +1 -0
- package/dist/test/debug-setJSONB.js.map +1 -0
- package/dist/test/prompt.test.d.ts +1 -0
- package/dist/test/prompt.test.js +74 -0
- package/dist/test/prompt.test.js.map +1 -0
- package/dist/test/s4-formatter.spec.d.ts +1 -0
- package/dist/test/s4-formatter.spec.js +67 -0
- package/dist/test/s4-formatter.spec.js.map +1 -0
- package/dist/test/s4-pagination.spec.d.ts +1 -0
- package/dist/test/s4-pagination.spec.js +170 -0
- package/dist/test/s4-pagination.spec.js.map +1 -0
- package/dist/test/safe-proxy.spec.d.ts +1 -0
- package/dist/test/safe-proxy.spec.js +252 -0
- package/dist/test/safe-proxy.spec.js.map +1 -0
- package/dist/test/serializer.spec.d.ts +1 -0
- package/dist/test/serializer.spec.js +27 -0
- package/dist/test/serializer.spec.js.map +1 -0
- package/dist/test/utils.spec.d.ts +1 -0
- package/dist/test/utils.spec.js +446 -0
- package/dist/test/utils.spec.js.map +1 -0
- package/dist/ts/cache/index.d.ts +33 -0
- package/dist/ts/cache/index.js +171 -0
- package/dist/ts/cache/index.js.map +1 -0
- package/dist/ts/configurations/server-config.d.ts +4 -0
- package/dist/ts/configurations/server-config.js +2 -0
- package/dist/ts/configurations/server-config.js.map +1 -0
- package/dist/ts/constants/index.d.ts +7 -0
- package/dist/ts/constants/index.js +8 -0
- package/dist/ts/constants/index.js.map +1 -0
- package/dist/ts/cycle/index.d.ts +53 -0
- package/dist/ts/cycle/index.js +169 -0
- package/dist/ts/cycle/index.js.map +1 -0
- package/dist/ts/dns/DnsCache.d.ts +50 -0
- package/dist/ts/dns/DnsCache.js +137 -0
- package/dist/ts/dns/DnsCache.js.map +1 -0
- package/dist/ts/dns/index.d.ts +4 -0
- package/dist/ts/dns/index.js +4 -0
- package/dist/ts/dns/index.js.map +1 -0
- package/dist/ts/formatter/index.d.ts +44 -0
- package/dist/ts/formatter/index.js +76 -0
- package/dist/ts/formatter/index.js.map +1 -0
- package/dist/ts/hal/index.d.ts +26 -0
- package/dist/ts/hal/index.js +70 -0
- package/dist/ts/hal/index.js.map +1 -0
- package/dist/ts/health/index.d.ts +53 -0
- package/dist/ts/health/index.js +165 -0
- package/dist/ts/health/index.js.map +1 -0
- package/dist/ts/helpers/index.d.ts +1 -0
- package/dist/ts/helpers/index.js +2 -0
- package/dist/ts/helpers/index.js.map +1 -0
- package/dist/ts/helpers/test-server-wrapper.d.ts +56 -0
- package/dist/ts/helpers/test-server-wrapper.js +144 -0
- package/dist/ts/helpers/test-server-wrapper.js.map +1 -0
- package/dist/ts/index.d.ts +22 -0
- package/dist/ts/index.js +27 -0
- package/dist/ts/index.js.map +1 -0
- package/dist/ts/last-commit/index.d.ts +12 -0
- package/dist/ts/last-commit/index.js +82 -0
- package/dist/ts/last-commit/index.js.map +1 -0
- package/dist/ts/logger/index.d.ts +3 -0
- package/dist/ts/logger/index.js +4 -0
- package/dist/ts/logger/index.js.map +1 -0
- package/dist/ts/logger/s4-logger.d.ts +23 -0
- package/dist/ts/logger/s4-logger.js +105 -0
- package/dist/ts/logger/s4-logger.js.map +1 -0
- package/dist/ts/paginator/index.d.ts +2 -0
- package/dist/ts/paginator/index.js +3 -0
- package/dist/ts/paginator/index.js.map +1 -0
- package/dist/ts/paginator/s4-pagination.d.ts +26 -0
- package/dist/ts/paginator/s4-pagination.js +49 -0
- package/dist/ts/paginator/s4-pagination.js.map +1 -0
- package/dist/ts/paginator/sql-pagination.d.ts +52 -0
- package/dist/ts/paginator/sql-pagination.js +157 -0
- package/dist/ts/paginator/sql-pagination.js.map +1 -0
- package/dist/ts/paper-trail/helpers.d.ts +14 -0
- package/dist/ts/paper-trail/helpers.js +74 -0
- package/dist/ts/paper-trail/helpers.js.map +1 -0
- package/dist/ts/paper-trail/index.d.ts +54 -0
- package/dist/ts/paper-trail/index.js +236 -0
- package/dist/ts/paper-trail/index.js.map +1 -0
- package/dist/ts/prompts/index.d.ts +21 -0
- package/dist/ts/prompts/index.js +68 -0
- package/dist/ts/prompts/index.js.map +1 -0
- package/dist/ts/queue/index.d.ts +232 -0
- package/dist/ts/queue/index.js +440 -0
- package/dist/ts/queue/index.js.map +1 -0
- package/dist/ts/queue/publisher.d.ts +41 -0
- package/dist/ts/queue/publisher.js +84 -0
- package/dist/ts/queue/publisher.js.map +1 -0
- package/dist/ts/queue/queue-logger.d.ts +10 -0
- package/dist/ts/queue/queue-logger.js +35 -0
- package/dist/ts/queue/queue-logger.js.map +1 -0
- package/dist/ts/queue/subscriber.d.ts +55 -0
- package/dist/ts/queue/subscriber.js +98 -0
- package/dist/ts/queue/subscriber.js.map +1 -0
- package/dist/ts/safe-proxy/index.d.ts +35 -0
- package/dist/ts/safe-proxy/index.js +54 -0
- package/dist/ts/safe-proxy/index.js.map +1 -0
- package/dist/ts/serializer/index.d.ts +52 -0
- package/dist/ts/serializer/index.js +83 -0
- package/dist/ts/serializer/index.js.map +1 -0
- package/dist/ts/task-scheduler/index.d.ts +130 -0
- package/dist/ts/task-scheduler/index.js +259 -0
- package/dist/ts/task-scheduler/index.js.map +1 -0
- package/dist/ts/utils/index.d.ts +49 -0
- package/dist/ts/utils/index.js +157 -0
- package/dist/ts/utils/index.js.map +1 -0
- package/package.json +10 -8
- package/paper-trail/index.js +2 -1
- package/queue/index.js +57 -69
- package/scripts/publish.sh +46 -0
- package/test/health.spec.js +213 -0
- package/test/prompt.test.js +91 -0
- package/test/s4-formatter.spec.js +80 -0
- package/test/s4-pagination.spec.js +196 -0
- package/test/serializer.spec.js +34 -0
- package/test/utils.spec.js +145 -0
- 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
|