@team-internet/apiconnector 10.0.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.
- package/.devcontainer/Dockerfile +66 -0
- package/.devcontainer/devcontainer.json +30 -0
- package/.devcontainer/docker-compose.yml +11 -0
- package/.devcontainer/supporting_files/configuration/.czrc +1 -0
- package/.devcontainer/supporting_files/configuration/.p10k.zsh +1735 -0
- package/.devcontainer/supporting_files/configuration/.zshrc +23 -0
- package/.devcontainer/supporting_files/configuration/p10k-instant-prompt-vscode.zsh +323 -0
- package/.devcontainer/supporting_files/scripts/post-create.sh +11 -0
- package/.nycrc +6 -0
- package/CHANGELOG.md +582 -0
- package/CONTRIBUTING.md +132 -0
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/apiclient.d.ts +233 -0
- package/dist/apiclient.js +517 -0
- package/dist/column.d.ts +40 -0
- package/dist/column.js +52 -0
- package/dist/customlogger.d.ts +15 -0
- package/dist/customlogger.js +23 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.js +21 -0
- package/dist/record.d.ts +31 -0
- package/dist/record.js +42 -0
- package/dist/response.d.ts +264 -0
- package/dist/response.js +512 -0
- package/dist/responseparser.d.ts +1 -0
- package/dist/responseparser.js +36 -0
- package/dist/responsetemplatemanager.d.ts +65 -0
- package/dist/responsetemplatemanager.js +111 -0
- package/dist/responsetranslator.d.ts +32 -0
- package/dist/responsetranslator.js +144 -0
- package/dist/socketconfig.d.ts +62 -0
- package/dist/socketconfig.js +107 -0
- package/package.json +86 -0
- package/src/apiclient.ts +579 -0
- package/src/column.ts +57 -0
- package/src/customlogger.ts +29 -0
- package/src/index.ts +18 -0
- package/src/logger.ts +23 -0
- package/src/record.ts +46 -0
- package/src/response.ts +562 -0
- package/src/responseparser.ts +35 -0
- package/src/responsetemplatemanager.ts +136 -0
- package/src/responsetranslator.ts +191 -0
- package/src/socketconfig.ts +116 -0
- package/tests/apiclient.spec.ts +610 -0
- package/tests/app.js +47 -0
- package/tests/column.spec.ts +23 -0
- package/tests/index.spec.ts +22 -0
- package/tests/record.spec.ts +31 -0
- package/tests/response.spec.ts +341 -0
- package/tests/responseparser.spec.ts +13 -0
- package/tests/responsetemplatemanager.spec.ts +52 -0
- package/tests/socketconfig.spec.ts +14 -0
- package/tsconfig.json +7 -0
- package/typedoc.json +7 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import { Record } from "../src/record.ts";
|
|
4
|
+
|
|
5
|
+
let rec: Record;
|
|
6
|
+
const data: any = {
|
|
7
|
+
DOMAIN: "mydomain.com",
|
|
8
|
+
RATING: "1",
|
|
9
|
+
RNDINT: "321",
|
|
10
|
+
SUM: "1",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
before(() => {
|
|
14
|
+
rec = new Record(data);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe("Record class", function () {
|
|
18
|
+
this.slow(1000);
|
|
19
|
+
|
|
20
|
+
describe("#.getData", () => {
|
|
21
|
+
it("check return value", () => {
|
|
22
|
+
expect(rec.getData()).to.equal(data);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("#.getDataByKey", () => {
|
|
27
|
+
it("check return value [column key not found]", () => {
|
|
28
|
+
expect(rec.getDataByKey("KEYNOTEXISTING")).to.be.null;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import { Response } from "../src/response.ts";
|
|
4
|
+
import { ResponseParser } from "../src/responseparser.ts";
|
|
5
|
+
import { ResponseTemplateManager } from "../src/responsetemplatemanager.ts";
|
|
6
|
+
|
|
7
|
+
const rtm = ResponseTemplateManager.getInstance();
|
|
8
|
+
const cmd = { COMMAND: "StatusContact" };
|
|
9
|
+
|
|
10
|
+
before(() => {
|
|
11
|
+
rtm
|
|
12
|
+
.addTemplate(
|
|
13
|
+
"listP0",
|
|
14
|
+
"[RESPONSE]\r\nproperty[total][0] = 4\r\nproperty[first][0] = 0\r\nproperty[domain][0] = cnic-ssl-test1.com\r\nproperty[domain][1] = cnic-ssl-test2.com\r\nproperty[count][0] = 2\r\nproperty[last][0] = 1\r\nproperty[limit][0] = 2\r\ndescription = Command completed successfully\r\ncode = 200\r\nqueuetime = 0\r\nruntime = 0.007\r\nEOF\r\n",
|
|
15
|
+
)
|
|
16
|
+
.addTemplate(
|
|
17
|
+
"pendingRegistration",
|
|
18
|
+
"[RESPONSE]\r\ncode = 200\r\ndescription = Command completed successfully\r\nruntime = 0.44\r\nqueuetime = 0\r\n\r\nproperty[status][0] = REQUESTED\r\nproperty[updated date][0] = 2023-05-22 12:14:31.0\r\nproperty[zone][0] = se\r\nEOF\r\n",
|
|
19
|
+
)
|
|
20
|
+
.addTemplate(
|
|
21
|
+
"OK",
|
|
22
|
+
rtm.generateTemplate("200", "Command completed successfully"),
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("Response class", function () {
|
|
27
|
+
this.slow(1000);
|
|
28
|
+
|
|
29
|
+
describe("constructor", () => {
|
|
30
|
+
it("check instance [raw empty string]", () => {
|
|
31
|
+
const tpl = new Response("");
|
|
32
|
+
expect(tpl.getCode()).to.equal(423);
|
|
33
|
+
expect(tpl.getDescription()).to.equal(
|
|
34
|
+
"Empty API response. Probably unreachable API end point",
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("check template `invalid` being returned", () => {
|
|
39
|
+
const tpl = new Response(
|
|
40
|
+
"[RESPONSE]\r\ncode=200\r\nqueuetime=0\r\nEOF\r\n",
|
|
41
|
+
);
|
|
42
|
+
expect(tpl.getCode()).to.equal(423);
|
|
43
|
+
expect(tpl.getDescription()).to.equal(
|
|
44
|
+
"Invalid API response. Contact Support",
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("check place holder vars replacment", () => {
|
|
49
|
+
// ensure no vars are returned in response, just in case no place holder replacements are provided
|
|
50
|
+
let r = new Response("", cmd);
|
|
51
|
+
expect(/\{[A-Z_]+\}/.test(r.getDescription())).to.be.false;
|
|
52
|
+
|
|
53
|
+
// ensure variable replacements are correctly handled in case place holder replacements are provided
|
|
54
|
+
r = new Response(
|
|
55
|
+
"",
|
|
56
|
+
{ COMMAND: "StatusAccount" },
|
|
57
|
+
{ CONNECTION_URL: "123HXPHFOUND123" },
|
|
58
|
+
);
|
|
59
|
+
expect(/123HXPHFOUND123/.test(r.getDescription())).to.be.true;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("#.getHash", () => {
|
|
64
|
+
it("check return value", () => {
|
|
65
|
+
const h = new Response("").getHash();
|
|
66
|
+
expect(h.CODE).to.equal("423");
|
|
67
|
+
expect(h.DESCRIPTION).to.equal(
|
|
68
|
+
"Empty API response. Probably unreachable API end point",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("#.getQueuetime", () => {
|
|
74
|
+
it("check return value [n/a in API response]", () => {
|
|
75
|
+
const tpl = new Response("");
|
|
76
|
+
expect(tpl.getQueuetime()).to.equal(0);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("check return value [in API response]", () => {
|
|
80
|
+
const tpl = new Response(
|
|
81
|
+
"[RESPONSE]\r\ncode = 423\r\ndescription = Empty API response. Probably unreachable API end point\r\nqueuetime = 0\r\nEOF\r\n",
|
|
82
|
+
);
|
|
83
|
+
expect(tpl.getQueuetime()).to.equal(0);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe("#.getRuntime", () => {
|
|
88
|
+
it("check return value [n/a in API response]", () => {
|
|
89
|
+
const tpl = new Response("");
|
|
90
|
+
expect(tpl.getRuntime()).to.equal(0);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("check return value [in API response]", () => {
|
|
94
|
+
const tpl = new Response(
|
|
95
|
+
"[RESPONSE]\r\ncode= 423 \r\ndescription = Empty API response. Probably unreachable API end point\r\nruntime = 0.12\r\nEOF\r\n",
|
|
96
|
+
);
|
|
97
|
+
expect(tpl.getRuntime()).to.equal(0.12);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("#.isPending", () => {
|
|
102
|
+
it("check return value [n/a in API response]", () => {
|
|
103
|
+
const tpl = new Response("");
|
|
104
|
+
expect(tpl.isPending()).to.be.false;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("check return value [in API response]", () => {
|
|
108
|
+
const tpl = new Response(
|
|
109
|
+
rtm.getTemplate("pendingRegistration").getPlain(),
|
|
110
|
+
{
|
|
111
|
+
COMMAND: "AddDomain",
|
|
112
|
+
DOMAIN: "example.com",
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
expect(tpl.isPending()).to.be.true;
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("#.getCommandPlain", () => {
|
|
120
|
+
it("check flattening of command works", () => {
|
|
121
|
+
const r = new Response("", {
|
|
122
|
+
COMMAND: "CheckDomains",
|
|
123
|
+
DOMAIN0: "example.com",
|
|
124
|
+
DOMAIN1: "example.net",
|
|
125
|
+
});
|
|
126
|
+
const expected =
|
|
127
|
+
"COMMAND = CheckDomains\nDOMAIN0 = example.com\nDOMAIN1 = example.net\n";
|
|
128
|
+
expect(r.getCommandPlain()).to.equal(expected);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("check data being returned secure", () => {
|
|
132
|
+
const r = new Response("", {
|
|
133
|
+
COMMAND: "CheckAuthentication",
|
|
134
|
+
SUBUSER: "test.user",
|
|
135
|
+
PASSWORD: "test.passw0rd",
|
|
136
|
+
});
|
|
137
|
+
const expected =
|
|
138
|
+
"COMMAND = CheckAuthentication\nSUBUSER = test.user\nPASSWORD = ***\n";
|
|
139
|
+
expect(r.getCommandPlain()).to.equal(expected);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("#.getCurrentPageNumber", () => {
|
|
144
|
+
it("check return value [w/ entries in response]", () => {
|
|
145
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
146
|
+
expect(r.getCurrentPageNumber()).to.equal(1);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("check return value [w/o entries in response]", () => {
|
|
150
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
151
|
+
expect(r.getCurrentPageNumber()).to.equal(null);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe("#.getColumns", () => {
|
|
156
|
+
it("check return value", () => {
|
|
157
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
158
|
+
const cols = r.getColumns();
|
|
159
|
+
expect(cols.length).to.equal(6);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("#.getColumnIndex", () => {
|
|
164
|
+
it("check return value [colum exists]", () => {
|
|
165
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
166
|
+
const data = r.getColumnIndex("DOMAIN", 0);
|
|
167
|
+
expect(data).to.equal("cnic-ssl-test1.com");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("check return value [colum does not exist]", () => {
|
|
171
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
172
|
+
const data = r.getColumnIndex("COLUMN_NOT_EXISTS", 0);
|
|
173
|
+
expect(data).to.be.null;
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe("#.getColumnKeys", () => {
|
|
178
|
+
it("check return value", () => {
|
|
179
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
180
|
+
const colkeys = r.getColumnKeys();
|
|
181
|
+
expect(colkeys.length).to.equal(6);
|
|
182
|
+
expect(colkeys).to.include.members([
|
|
183
|
+
"COUNT",
|
|
184
|
+
"DOMAIN",
|
|
185
|
+
"FIRST",
|
|
186
|
+
"LAST",
|
|
187
|
+
"LIMIT",
|
|
188
|
+
"TOTAL",
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe("#.getCurrentRecord", () => {
|
|
194
|
+
it("check return value", () => {
|
|
195
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
196
|
+
const rec = r.getCurrentRecord();
|
|
197
|
+
expect(rec).not.to.be.null;
|
|
198
|
+
if (rec) {
|
|
199
|
+
expect(rec.getData()).to.eql({
|
|
200
|
+
COUNT: "2",
|
|
201
|
+
DOMAIN: "cnic-ssl-test1.com",
|
|
202
|
+
FIRST: "0",
|
|
203
|
+
LAST: "1",
|
|
204
|
+
LIMIT: "2",
|
|
205
|
+
TOTAL: "4",
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("check return value [no records available]", () => {
|
|
211
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
212
|
+
expect(r.getCurrentRecord()).to.be.null;
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe("#.getListHash", () => {
|
|
217
|
+
it("check return value", () => {
|
|
218
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
219
|
+
const lh = r.getListHash();
|
|
220
|
+
expect(lh.LIST.length).to.equal(2);
|
|
221
|
+
expect(lh.meta.columns).to.eql(r.getColumnKeys());
|
|
222
|
+
expect(lh.meta.pg).to.eql(r.getPagination());
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe("#.getNextRecord", () => {
|
|
227
|
+
it("check return value", () => {
|
|
228
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
229
|
+
let rec = r.getNextRecord();
|
|
230
|
+
expect(rec).not.to.be.null;
|
|
231
|
+
if (rec) {
|
|
232
|
+
expect(rec.getData()).to.eql({ DOMAIN: "cnic-ssl-test2.com" });
|
|
233
|
+
}
|
|
234
|
+
rec = r.getNextRecord();
|
|
235
|
+
expect(rec).to.be.null;
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe("#.getPagination", () => {
|
|
240
|
+
it("check return value [next record]", () => {
|
|
241
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
242
|
+
const pager = r.getPagination();
|
|
243
|
+
expect(pager).to.have.all.keys([
|
|
244
|
+
"COUNT",
|
|
245
|
+
"CURRENTPAGE",
|
|
246
|
+
"FIRST",
|
|
247
|
+
"LAST",
|
|
248
|
+
"LIMIT",
|
|
249
|
+
"NEXTPAGE",
|
|
250
|
+
"PAGES",
|
|
251
|
+
"PREVIOUSPAGE",
|
|
252
|
+
"TOTAL",
|
|
253
|
+
]);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe("#.getPreviousRecord", () => {
|
|
258
|
+
it("check return value", () => {
|
|
259
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
260
|
+
r.getNextRecord();
|
|
261
|
+
const rec = r.getPreviousRecord();
|
|
262
|
+
expect(rec).not.to.be.null;
|
|
263
|
+
if (rec) {
|
|
264
|
+
expect(rec.getData()).to.eql({
|
|
265
|
+
COUNT: "2",
|
|
266
|
+
DOMAIN: "cnic-ssl-test1.com",
|
|
267
|
+
FIRST: "0",
|
|
268
|
+
LAST: "1",
|
|
269
|
+
LIMIT: "2",
|
|
270
|
+
TOTAL: "4",
|
|
271
|
+
});
|
|
272
|
+
expect(r.getPreviousRecord()).to.be.null;
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
describe("#.hasNextPage", () => {
|
|
278
|
+
it("check return value [no rows]", () => {
|
|
279
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
280
|
+
expect(r.hasNextPage()).to.be.false;
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("check return value [rows]", () => {
|
|
284
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
285
|
+
expect(r.hasNextPage()).to.be.true;
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe("#.hasPreviousPage", () => {
|
|
290
|
+
it("check return value [no rows]", () => {
|
|
291
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
292
|
+
expect(r.hasPreviousPage()).to.be.false;
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it("check return value [rows]", () => {
|
|
296
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
297
|
+
expect(r.hasPreviousPage()).to.be.false;
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe("#.getNextPageNumber", () => {
|
|
302
|
+
it("check return value [no rows]", () => {
|
|
303
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
304
|
+
expect(r.getNextPageNumber()).to.be.null;
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("check return value [rows]", () => {
|
|
308
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
309
|
+
expect(r.getNextPageNumber()).to.be.equal(2);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
describe("#.getNumberOfPages", () => {
|
|
314
|
+
it("check return value [no rows]", () => {
|
|
315
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
316
|
+
expect(r.getNumberOfPages()).to.equal(0);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
describe("#.getPreviousPageNumber", () => {
|
|
321
|
+
it("check return value [no rows]", () => {
|
|
322
|
+
const r = new Response(rtm.getTemplate("OK").getPlain(), cmd);
|
|
323
|
+
expect(r.getPreviousPageNumber()).to.be.null;
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("check return value [rows]", () => {
|
|
327
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
328
|
+
expect(r.getPreviousPageNumber()).to.be.null;
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
describe("#.rewindRecordList", () => {
|
|
333
|
+
it("check return value", () => {
|
|
334
|
+
const r = new Response(rtm.getTemplate("listP0").getPlain(), cmd);
|
|
335
|
+
expect(r.getPreviousRecord()).to.be.null;
|
|
336
|
+
expect(r.getNextRecord()).not.to.be.null;
|
|
337
|
+
expect(r.getNextRecord()).to.be.null;
|
|
338
|
+
expect(r.rewindRecordList().getPreviousRecord()).to.be.null;
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import { ResponseParser } from "../src/responseparser.ts";
|
|
4
|
+
import { ResponseTemplateManager } from "../src/responsetemplatemanager.ts";
|
|
5
|
+
|
|
6
|
+
const rtm = ResponseTemplateManager.getInstance();
|
|
7
|
+
|
|
8
|
+
before(() => {
|
|
9
|
+
rtm.addTemplate(
|
|
10
|
+
"OK",
|
|
11
|
+
rtm.generateTemplate("200", "Command completed successfully"),
|
|
12
|
+
);
|
|
13
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import { Response } from "../src/response.ts";
|
|
4
|
+
import { ResponseTemplateManager } from "../src/responsetemplatemanager.ts";
|
|
5
|
+
|
|
6
|
+
let rtm: ResponseTemplateManager;
|
|
7
|
+
|
|
8
|
+
before(() => {
|
|
9
|
+
rtm = ResponseTemplateManager.getInstance();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe("ResponseTemplateManager class", function () {
|
|
13
|
+
this.slow(1000);
|
|
14
|
+
|
|
15
|
+
describe("#.getTemplate", () => {
|
|
16
|
+
it("check return value [template not found]", () => {
|
|
17
|
+
const tpl = rtm.getTemplate("IwontExist");
|
|
18
|
+
expect(tpl.getCode()).to.equal(500);
|
|
19
|
+
expect(tpl.getDescription()).to.equal("Response Template not found");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("#.getTemplates", () => {
|
|
24
|
+
it("check return value", () => {
|
|
25
|
+
const defaultones = [
|
|
26
|
+
"404",
|
|
27
|
+
"500",
|
|
28
|
+
"error",
|
|
29
|
+
"httperror",
|
|
30
|
+
"invalid",
|
|
31
|
+
"empty",
|
|
32
|
+
"unauthorized",
|
|
33
|
+
"expired",
|
|
34
|
+
];
|
|
35
|
+
expect(rtm.getTemplates()).to.include.all.keys(defaultones);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("#.isTemplateMatchHash", () => {
|
|
40
|
+
it("check return value [matched]", () => {
|
|
41
|
+
const tpl = new Response("");
|
|
42
|
+
expect(rtm.isTemplateMatchHash(tpl.getHash(), "empty")).to.be.true;
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("#.isTemplateMatchPlain", () => {
|
|
47
|
+
it("check return value [matched]", () => {
|
|
48
|
+
const tpl = new Response("");
|
|
49
|
+
expect(rtm.isTemplateMatchPlain(tpl.getPlain(), "empty")).to.be.true;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import "mocha";
|
|
3
|
+
import { SocketConfig } from "../src/socketconfig.ts";
|
|
4
|
+
|
|
5
|
+
describe("SocketConfig class", function () {
|
|
6
|
+
this.slow(1000);
|
|
7
|
+
|
|
8
|
+
describe("#.getPOSTData", () => {
|
|
9
|
+
it("check return value [no settings made]", () => {
|
|
10
|
+
const d = new SocketConfig().getPOSTData();
|
|
11
|
+
expect(d).to.be.empty;
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
package/tsconfig.json
ADDED