@villedemontreal/http-request 7.4.7 → 7.4.8

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.
@@ -2,6 +2,15 @@
2
2
  // Ok in test files :
3
3
  // tslint:disable:no-string-literal
4
4
  // tslint:disable: max-func-body-length
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
15
  const src_1 = require("@villedemontreal/general-utils/dist/src");
7
16
  const chai_1 = require("chai");
@@ -21,77 +30,77 @@ const superagentMocker = require('superagent-mocker');
21
30
  (0, testingConfigurations_1.setTestingConfigurations)();
22
31
  describe('httpUtils', () => {
23
32
  describe('urlJoin', () => {
24
- it('single param with slash', async () => {
33
+ it('single param with slash', () => __awaiter(void 0, void 0, void 0, function* () {
25
34
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/'), 'http://google.com');
26
- });
27
- it('single param no slash', async () => {
35
+ }));
36
+ it('single param no slash', () => __awaiter(void 0, void 0, void 0, function* () {
28
37
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com'), 'http://google.com');
29
- });
30
- it('with slashes', async () => {
38
+ }));
39
+ it('with slashes', () => __awaiter(void 0, void 0, void 0, function* () {
31
40
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', 'foo/', '/bar/'), 'http://google.com/foo/bar');
32
- });
33
- it('without slashes', async () => {
41
+ }));
42
+ it('without slashes', () => __awaiter(void 0, void 0, void 0, function* () {
34
43
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com', 'foo', 'bar'), 'http://google.com/foo/bar');
35
- });
36
- it('without double slashes', async () => {
44
+ }));
45
+ it('without double slashes', () => __awaiter(void 0, void 0, void 0, function* () {
37
46
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', '//foo/', '//bar/'), 'http://google.com/foo/bar');
38
- });
39
- it('with slashes without text', async () => {
47
+ }));
48
+ it('with slashes without text', () => __awaiter(void 0, void 0, void 0, function* () {
40
49
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', '///', '//bar/'), 'http://google.com/bar');
41
- });
42
- it('with slashes and empty text', async () => {
50
+ }));
51
+ it('with slashes and empty text', () => __awaiter(void 0, void 0, void 0, function* () {
43
52
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', '', '//bar/'), 'http://google.com/bar');
44
- });
45
- it('with slashes and null text', async () => {
53
+ }));
54
+ it('with slashes and null text', () => __awaiter(void 0, void 0, void 0, function* () {
46
55
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', null, '//bar/'), 'http://google.com/bar');
47
- });
48
- it('with slashes and undefined text', async () => {
56
+ }));
57
+ it('with slashes and undefined text', () => __awaiter(void 0, void 0, void 0, function* () {
49
58
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://google.com/', undefined, '//bar/'), 'http://google.com/bar');
50
- });
51
- it('with http 2 slashes', async () => {
59
+ }));
60
+ it('with http 2 slashes', () => __awaiter(void 0, void 0, void 0, function* () {
52
61
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://', 'google.com', 'foo', 'bar'), 'http://google.com/foo/bar');
53
- });
54
- it('with http 1 slash', async () => {
62
+ }));
63
+ it('with http 1 slash', () => __awaiter(void 0, void 0, void 0, function* () {
55
64
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http:/', 'google.com', 'foo', 'bar'), 'http://google.com/foo/bar');
56
- });
57
- it('with http no slash', async () => {
65
+ }));
66
+ it('with http no slash', () => __awaiter(void 0, void 0, void 0, function* () {
58
67
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http:', 'google.com', 'foo', 'bar'), 'http://google.com/foo/bar');
59
- });
60
- it('another example', async () => {
68
+ }));
69
+ it('another example', () => __awaiter(void 0, void 0, void 0, function* () {
61
70
  chai_1.assert.equal(httpUtils_1.httpUtils.urlJoin('http://api.montreal.ca/accounts/', '/inum', '@5441521452', 'tickets'), 'http://api.montreal.ca/accounts/inum/@5441521452/tickets');
62
- });
71
+ }));
63
72
  });
64
73
  describe('send', () => {
65
74
  describe('mocked', () => {
66
75
  let mock;
67
- before(async () => {
76
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
68
77
  mock = superagentMocker(superagent);
69
78
  mock.get('http://localhost/test', (req) => {
70
79
  return {
71
80
  body: {
72
- headers: req.headers
73
- }
81
+ headers: req.headers,
82
+ },
74
83
  };
75
84
  });
76
- });
77
- after(async () => {
85
+ }));
86
+ after(() => __awaiter(void 0, void 0, void 0, function* () {
78
87
  mock.clearRoutes();
79
88
  mock.unmock(superagent);
80
- });
81
- it('URL must have a hostname', async () => {
89
+ }));
90
+ it('URL must have a hostname', () => __awaiter(void 0, void 0, void 0, function* () {
82
91
  const request = superagent.get('/test');
83
92
  try {
84
- await httpUtils_1.httpUtils.send(request);
93
+ yield httpUtils_1.httpUtils.send(request);
85
94
  chai_1.assert.fail('expected send to throw an error');
86
95
  }
87
96
  catch (err) {
88
97
  chai_1.assert.strictEqual(err.message, 'The URL in your request MUST have a protocol and a hostname. Received: /test');
89
98
  }
90
- });
91
- it('The Correlation Id is set automatically', async () => {
99
+ }));
100
+ it('The Correlation Id is set automatically', () => __awaiter(void 0, void 0, void 0, function* () {
92
101
  const currentCid = configs_1.configs.correlationId;
93
102
  const request = superagent.get('http://localhost/test').set('titi', '123');
94
- const response = await httpUtils_1.httpUtils.send(request);
103
+ const response = yield httpUtils_1.httpUtils.send(request);
95
104
  chai_1.assert.isOk(response);
96
105
  chai_1.assert.isOk(response.status);
97
106
  chai_1.assert.strictEqual(response.status, 200);
@@ -100,95 +109,95 @@ describe('httpUtils', () => {
100
109
  const headers = response.body.headers;
101
110
  chai_1.assert.strictEqual(headers.titi, '123');
102
111
  chai_1.assert.strictEqual(headers[http_header_fields_typed_1.default.X_CORRELATION_ID.toLowerCase()], currentCid);
103
- });
104
- it('Regular response response', async () => {
112
+ }));
113
+ it('Regular response response', () => __awaiter(void 0, void 0, void 0, function* () {
105
114
  for (const status of [200, 201, 301, 400, 404, 500, 501]) {
106
115
  mock.get('http://localhost/test', (req) => {
107
116
  return {
108
117
  status,
109
118
  body: {
110
- msg: 'titi'
111
- }
119
+ msg: 'titi',
120
+ },
112
121
  };
113
122
  });
114
123
  const request = superagent.get('http://localhost/test');
115
- const response = await httpUtils_1.httpUtils.send(request);
124
+ const response = yield httpUtils_1.httpUtils.send(request);
116
125
  chai_1.assert.isOk(response);
117
126
  chai_1.assert.isOk(response.status);
118
127
  chai_1.assert.strictEqual(response.status, status);
119
128
  chai_1.assert.isObject(response.body);
120
129
  chai_1.assert.strictEqual(response.body.msg, 'titi');
121
130
  }
122
- });
123
- it('Timeouts are added, if not already set', async () => {
131
+ }));
132
+ it('Timeouts are added, if not already set', () => __awaiter(void 0, void 0, void 0, function* () {
124
133
  const request = superagent.get('http://localhost/test').set('titi', '123');
125
134
  chai_1.assert.isUndefined(request['_responseTimeout']);
126
135
  chai_1.assert.isUndefined(request['_timeout']);
127
- const response = await httpUtils_1.httpUtils.send(request);
136
+ const response = yield httpUtils_1.httpUtils.send(request);
128
137
  chai_1.assert.isOk(response);
129
138
  chai_1.assert.strictEqual(request['_responseTimeout'], constants_1.constants.request.timeoutsDefault.response);
130
139
  chai_1.assert.strictEqual(request['_timeout'], constants_1.constants.request.timeoutsDefault.deadline);
131
- });
132
- it('Response timeout already set', async () => {
140
+ }));
141
+ it('Response timeout already set', () => __awaiter(void 0, void 0, void 0, function* () {
133
142
  const request = superagent.get('http://localhost/test').set('titi', '123');
134
143
  request.timeout({
135
- response: 55555
144
+ response: 55555,
136
145
  });
137
146
  chai_1.assert.strictEqual(request['_responseTimeout'], 55555);
138
147
  chai_1.assert.isUndefined(request['_timeout']);
139
- const response = await httpUtils_1.httpUtils.send(request);
148
+ const response = yield httpUtils_1.httpUtils.send(request);
140
149
  chai_1.assert.isOk(response);
141
150
  chai_1.assert.strictEqual(request['_responseTimeout'], 55555);
142
151
  chai_1.assert.strictEqual(request['_timeout'], constants_1.constants.request.timeoutsDefault.deadline);
143
- });
144
- it('Deadline timeout already set', async () => {
152
+ }));
153
+ it('Deadline timeout already set', () => __awaiter(void 0, void 0, void 0, function* () {
145
154
  const request = superagent.get('http://localhost/test').set('titi', '123');
146
155
  request.timeout({
147
- deadline: 55555
156
+ deadline: 55555,
148
157
  });
149
158
  chai_1.assert.isUndefined(request['_responseTimeout']);
150
159
  chai_1.assert.strictEqual(request['_timeout'], 55555);
151
- const response = await httpUtils_1.httpUtils.send(request);
160
+ const response = yield httpUtils_1.httpUtils.send(request);
152
161
  chai_1.assert.isOk(response);
153
162
  chai_1.assert.strictEqual(request['_responseTimeout'], constants_1.constants.request.timeoutsDefault.response);
154
163
  chai_1.assert.strictEqual(request['_timeout'], 55555);
155
- });
156
- it('Both timeouts timeout already set', async () => {
164
+ }));
165
+ it('Both timeouts timeout already set', () => __awaiter(void 0, void 0, void 0, function* () {
157
166
  const request = superagent.get('http://localhost/test').set('titi', '123');
158
167
  request.timeout({
159
168
  deadline: 55555,
160
- response: 66666
169
+ response: 66666,
161
170
  });
162
171
  chai_1.assert.strictEqual(request['_responseTimeout'], 66666);
163
172
  chai_1.assert.strictEqual(request['_timeout'], 55555);
164
- const response = await httpUtils_1.httpUtils.send(request);
173
+ const response = yield httpUtils_1.httpUtils.send(request);
165
174
  chai_1.assert.isOk(response);
166
175
  chai_1.assert.strictEqual(request['_responseTimeout'], 66666);
167
176
  chai_1.assert.strictEqual(request['_timeout'], 55555);
168
- });
177
+ }));
169
178
  });
170
179
  describe('Network/Server error', () => {
171
- it('Network/Server error', async () => {
180
+ it('Network/Server error', () => __awaiter(void 0, void 0, void 0, function* () {
172
181
  const mock = superagentMocker(superagent);
173
182
  mock.get('http://localhost/test', (req) => {
174
183
  throw new Error('Network error');
175
184
  });
176
185
  try {
177
186
  const request = superagent.get('http://localhost/test');
178
- const response = await httpUtils_1.httpUtils.send(request);
187
+ const response = yield httpUtils_1.httpUtils.send(request);
179
188
  chai_1.assert.isNotOk(response);
180
189
  chai_1.assert.fail();
181
190
  }
182
191
  catch (err) {
183
192
  /* ok */
184
193
  }
185
- });
194
+ }));
186
195
  });
187
196
  describe('not mocked', () => {
188
- it('Errors are handled properly', async () => {
197
+ it('Errors are handled properly', () => __awaiter(void 0, void 0, void 0, function* () {
189
198
  try {
190
199
  const request = superagent.get('httttp://nope').timeout(100);
191
- const response = await httpUtils_1.httpUtils.send(request);
200
+ const response = yield httpUtils_1.httpUtils.send(request);
192
201
  chai_1.assert.isNotOk(response);
193
202
  chai_1.assert.fail();
194
203
  }
@@ -197,7 +206,7 @@ describe('httpUtils', () => {
197
206
  chai_1.assert.isTrue('msg' in err);
198
207
  chai_1.assert.isTrue('originalError' in err);
199
208
  }
200
- });
209
+ }));
201
210
  });
202
211
  });
203
212
  describe(`Express request related tests`, () => {
@@ -205,34 +214,38 @@ describe('httpUtils', () => {
205
214
  let server;
206
215
  let port;
207
216
  let expressRequest;
208
- async function startServer(caseSensitive) {
209
- app = express();
210
- app.set('case sensitive routing', caseSensitive);
211
- app.get('/', async (req, res, next) => {
212
- expressRequest = req;
213
- res.sendStatus(HttpStatusCodes.OK);
217
+ function startServer(caseSensitive) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ app = express();
220
+ app.set('case sensitive routing', caseSensitive);
221
+ app.get('/', (req, res, next) => __awaiter(this, void 0, void 0, function* () {
222
+ expressRequest = req;
223
+ res.sendStatus(HttpStatusCodes.OK);
224
+ }));
225
+ port = yield src_1.utils.findFreePort();
226
+ server = yield app.listen(port);
214
227
  });
215
- port = await src_1.utils.findFreePort();
216
- server = await app.listen(port);
217
228
  }
218
- async function send(pathAndQueryString) {
219
- const superagentRequest = superagent.get(`http://localhost:${port}${pathAndQueryString}`);
220
- const response = await httpUtils_1.httpUtils.send(superagentRequest);
221
- chai_1.assert.strictEqual(response.status, HttpStatusCodes.OK);
229
+ function send(pathAndQueryString) {
230
+ return __awaiter(this, void 0, void 0, function* () {
231
+ const superagentRequest = superagent.get(`http://localhost:${port}${pathAndQueryString}`);
232
+ const response = yield httpUtils_1.httpUtils.send(superagentRequest);
233
+ chai_1.assert.strictEqual(response.status, HttpStatusCodes.OK);
234
+ });
222
235
  }
223
236
  describe(`Query params functions - Case sensitive`, () => {
224
- before(async () => {
237
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
225
238
  // ==========================================
226
239
  // Set the configs for case sensitivity!
227
240
  // ==========================================
228
241
  (0, testingConfigurations_1.setTestingConfigurations)(true);
229
- await startServer(true);
230
- });
242
+ yield startServer(true);
243
+ }));
231
244
  after(() => {
232
245
  server.close();
233
246
  });
234
- it(`no query params`, async () => {
235
- await send(`/`);
247
+ it(`no query params`, () => __awaiter(void 0, void 0, void 0, function* () {
248
+ yield send(`/`);
236
249
  const values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
237
250
  chai_1.assert.deepEqual(values, []);
238
251
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -243,9 +256,9 @@ describe('httpUtils', () => {
243
256
  chai_1.assert.deepEqual(value, undefined);
244
257
  value = httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
245
258
  chai_1.assert.deepEqual(value, undefined);
246
- });
247
- it(`one query params - simple string`, async () => {
248
- await send(`/?k=toto`);
259
+ }));
260
+ it(`one query params - simple string`, () => __awaiter(void 0, void 0, void 0, function* () {
261
+ yield send(`/?k=toto`);
249
262
  let values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
250
263
  chai_1.assert.deepEqual(values, ['toto']);
251
264
  values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'K'); // case sensitive
@@ -300,10 +313,10 @@ describe('httpUtils', () => {
300
313
  return 123;
301
314
  });
302
315
  chai_1.assert.deepEqual(value, 123);
303
- });
304
- it('one query params - date string', async () => {
316
+ }));
317
+ it('one query params - date string', () => __awaiter(void 0, void 0, void 0, function* () {
305
318
  const dateStr = '2020-04-21T17:13:33.107Z';
306
- await send(`/?k=${encodeURIComponent(dateStr)}`);
319
+ yield send(`/?k=${encodeURIComponent(dateStr)}`);
307
320
  const values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
308
321
  chai_1.assert.deepEqual(values, [dateStr]);
309
322
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -358,10 +371,10 @@ describe('httpUtils', () => {
358
371
  chai_1.assert.fail();
359
372
  }
360
373
  chai_1.assert.deepEqual(error.message, `Custom Error`);
361
- });
362
- it('one query params - number string', async () => {
374
+ }));
375
+ it('one query params - number string', () => __awaiter(void 0, void 0, void 0, function* () {
363
376
  const testNumber = 123;
364
- await send(`/?k=${testNumber}`);
377
+ yield send(`/?k=${testNumber}`);
365
378
  const values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
366
379
  chai_1.assert.deepEqual(values, [testNumber + '']);
367
380
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -388,18 +401,18 @@ describe('httpUtils', () => {
388
401
  if (!error) {
389
402
  chai_1.assert.fail();
390
403
  }
391
- });
392
- it(`one query params - boolean`, async () => {
393
- await send(`/?k=true`);
404
+ }));
405
+ it(`one query params - boolean`, () => __awaiter(void 0, void 0, void 0, function* () {
406
+ yield send(`/?k=true`);
394
407
  let value = httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
395
408
  chai_1.assert.deepEqual(value, true);
396
- await send(`/?k=TrUe`);
409
+ yield send(`/?k=TrUe`);
397
410
  value = httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
398
411
  chai_1.assert.deepEqual(value, true);
399
- await send(`/?k=false`);
412
+ yield send(`/?k=false`);
400
413
  value = httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
401
414
  chai_1.assert.deepEqual(value, false);
402
- await send(`/?k=0`);
415
+ yield send(`/?k=0`);
403
416
  let error;
404
417
  try {
405
418
  httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
@@ -410,7 +423,7 @@ describe('httpUtils', () => {
410
423
  if (!error) {
411
424
  chai_1.assert.fail();
412
425
  }
413
- await send(`/?k=1`);
426
+ yield send(`/?k=1`);
414
427
  try {
415
428
  httpUtils_1.httpUtils.getQueryParamOneAsBoolean(expressRequest, 'k');
416
429
  }
@@ -420,9 +433,9 @@ describe('httpUtils', () => {
420
433
  if (!error) {
421
434
  chai_1.assert.fail();
422
435
  }
423
- });
424
- it('two different query params', async () => {
425
- await send(`/?k1=123&k2=titi`);
436
+ }));
437
+ it('two different query params', () => __awaiter(void 0, void 0, void 0, function* () {
438
+ yield send(`/?k1=123&k2=titi`);
426
439
  let values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k1');
427
440
  chai_1.assert.deepEqual(values, ['123']);
428
441
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k1');
@@ -431,9 +444,9 @@ describe('httpUtils', () => {
431
444
  chai_1.assert.deepEqual(values, ['titi']);
432
445
  value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k2');
433
446
  chai_1.assert.deepEqual(value, 'titi');
434
- });
435
- it('two different query params, different only by casing!', async () => {
436
- await send(`/?k=123&K=titi`);
447
+ }));
448
+ it('two different query params, different only by casing!', () => __awaiter(void 0, void 0, void 0, function* () {
449
+ yield send(`/?k=123&K=titi`);
437
450
  let values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
438
451
  chai_1.assert.deepEqual(values, ['123']);
439
452
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -442,11 +455,11 @@ describe('httpUtils', () => {
442
455
  chai_1.assert.deepEqual(values, ['titi']);
443
456
  value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'K');
444
457
  chai_1.assert.deepEqual(value, 'titi');
445
- });
446
- it('One query param with multiple values - first value is a number, second value is a date', async () => {
458
+ }));
459
+ it('One query param with multiple values - first value is a number, second value is a date', () => __awaiter(void 0, void 0, void 0, function* () {
447
460
  const dateStr = '2020-04-21T17:13:33.107Z';
448
461
  const testNumber = 123;
449
- await send(`/?k=${testNumber}&k=${encodeURIComponent(dateStr)}`);
462
+ yield send(`/?k=${testNumber}&k=${encodeURIComponent(dateStr)}`);
450
463
  const values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
451
464
  chai_1.assert.deepEqual(values, [testNumber + '', dateStr]);
452
465
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -465,11 +478,11 @@ describe('httpUtils', () => {
465
478
  if (!error) {
466
479
  chai_1.assert.fail();
467
480
  }
468
- });
469
- it('One query param with multiple values - first value is a date, second value is a number', async () => {
481
+ }));
482
+ it('One query param with multiple values - first value is a date, second value is a number', () => __awaiter(void 0, void 0, void 0, function* () {
470
483
  const dateStr = '2020-04-21T17:13:33.107Z';
471
484
  const testNumber = 123;
472
- await send(`/?k=${encodeURIComponent(dateStr)}&k=${testNumber}`);
485
+ yield send(`/?k=${encodeURIComponent(dateStr)}&k=${testNumber}`);
473
486
  const values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k');
474
487
  chai_1.assert.deepEqual(values, [dateStr, testNumber + '']);
475
488
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k');
@@ -481,21 +494,21 @@ describe('httpUtils', () => {
481
494
  // last value wins and can be parsed to a number
482
495
  value = httpUtils_1.httpUtils.getQueryParamOneAsNumber(expressRequest, 'k');
483
496
  chai_1.assert.deepEqual(value, testNumber);
484
- });
497
+ }));
485
498
  });
486
499
  describe('Query params functions - Case insensitive', () => {
487
- before(async () => {
500
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
488
501
  // ==========================================
489
502
  // Set the configs for case insensitivity!
490
503
  // ==========================================
491
504
  (0, testingConfigurations_1.setTestingConfigurations)(false);
492
- await startServer(false);
493
- });
505
+ yield startServer(false);
506
+ }));
494
507
  after(() => {
495
508
  server.close();
496
509
  });
497
- it('two different query params, different by casing!', async () => {
498
- await send(`/?k=123&K=titi`);
510
+ it('two different query params, different by casing!', () => __awaiter(void 0, void 0, void 0, function* () {
511
+ yield send(`/?k=123&K=titi`);
499
512
  let values = httpUtils_1.httpUtils.getQueryParamAll(expressRequest, 'k'); // lowercase
500
513
  chai_1.assert.deepEqual(values, ['123', 'titi']);
501
514
  let value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'k'); // lowercase
@@ -504,124 +517,124 @@ describe('httpUtils', () => {
504
517
  chai_1.assert.deepEqual(values, ['123', 'titi']);
505
518
  value = httpUtils_1.httpUtils.getQueryParamOne(expressRequest, 'K'); // uppercase
506
519
  chai_1.assert.deepEqual(value, 'titi'); // last value wins
507
- });
520
+ }));
508
521
  });
509
522
  describe('getOrderBys - Case insensitive', () => {
510
- before(async () => {
523
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
511
524
  (0, testingConfigurations_1.setTestingConfigurations)(false);
512
- await startServer(false);
513
- });
525
+ yield startServer(false);
526
+ }));
514
527
  after(() => {
515
528
  server.close();
516
529
  });
517
- it('Nil', async () => {
518
- await send(`/`);
530
+ it('Nil', () => __awaiter(void 0, void 0, void 0, function* () {
531
+ yield send(`/`);
519
532
  let orderBys = httpUtils_1.httpUtils.getOrderBys(null);
520
533
  chai_1.assert.deepEqual(orderBys, []);
521
534
  orderBys = httpUtils_1.httpUtils.getOrderBys(undefined);
522
535
  chai_1.assert.deepEqual(orderBys, []);
523
- });
524
- it('No orderBys', async () => {
525
- await send(`/`);
536
+ }));
537
+ it('No orderBys', () => __awaiter(void 0, void 0, void 0, function* () {
538
+ yield send(`/`);
526
539
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
527
540
  chai_1.assert.deepEqual(orderBys, []);
528
- });
529
- it('one orderBy, default is asc', async () => {
530
- await send(`/?orderBy=name`);
541
+ }));
542
+ it('one orderBy, default is asc', () => __awaiter(void 0, void 0, void 0, function* () {
543
+ yield send(`/?orderBy=name`);
531
544
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
532
545
  chai_1.assert.deepEqual(orderBys, [
533
546
  {
534
547
  key: 'name',
535
- direction: src_1.OrderByDirection.ASC
536
- }
548
+ direction: src_1.OrderByDirection.ASC,
549
+ },
537
550
  ]);
538
- });
539
- it('one orderBy, explicit asc', async () => {
540
- await send(`/?orderBy=+name`);
551
+ }));
552
+ it('one orderBy, explicit asc', () => __awaiter(void 0, void 0, void 0, function* () {
553
+ yield send(`/?orderBy=+name`);
541
554
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
542
555
  chai_1.assert.deepEqual(orderBys, [
543
556
  {
544
557
  key: 'name',
545
- direction: src_1.OrderByDirection.ASC
546
- }
558
+ direction: src_1.OrderByDirection.ASC,
559
+ },
547
560
  ]);
548
- });
549
- it('one orderBy, desc', async () => {
550
- await send(`/?orderBy=-name`);
561
+ }));
562
+ it('one orderBy, desc', () => __awaiter(void 0, void 0, void 0, function* () {
563
+ yield send(`/?orderBy=-name`);
551
564
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
552
565
  chai_1.assert.deepEqual(orderBys, [
553
566
  {
554
567
  key: 'name',
555
- direction: src_1.OrderByDirection.DESC
556
- }
568
+ direction: src_1.OrderByDirection.DESC,
569
+ },
557
570
  ]);
558
- });
559
- it('multiple orderBys', async () => {
560
- await send(`/?orderBy=-name,age,+nick,-color`);
571
+ }));
572
+ it('multiple orderBys', () => __awaiter(void 0, void 0, void 0, function* () {
573
+ yield send(`/?orderBy=-name,age,+nick,-color`);
561
574
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
562
575
  chai_1.assert.deepEqual(orderBys, [
563
576
  {
564
577
  key: 'name',
565
- direction: src_1.OrderByDirection.DESC
578
+ direction: src_1.OrderByDirection.DESC,
566
579
  },
567
580
  {
568
581
  key: 'age',
569
- direction: src_1.OrderByDirection.ASC
582
+ direction: src_1.OrderByDirection.ASC,
570
583
  },
571
584
  {
572
585
  key: 'nick',
573
- direction: src_1.OrderByDirection.ASC
586
+ direction: src_1.OrderByDirection.ASC,
574
587
  },
575
588
  {
576
589
  key: 'color',
577
- direction: src_1.OrderByDirection.DESC
578
- }
590
+ direction: src_1.OrderByDirection.DESC,
591
+ },
579
592
  ]);
580
- });
581
- it('The case sensitivity of the "orderBy" key is not important', async () => {
582
- await send(`/?ORDERBY=-name`);
593
+ }));
594
+ it('The case sensitivity of the "orderBy" key is not important', () => __awaiter(void 0, void 0, void 0, function* () {
595
+ yield send(`/?ORDERBY=-name`);
583
596
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
584
597
  chai_1.assert.deepEqual(orderBys, [
585
598
  {
586
599
  key: 'name',
587
- direction: src_1.OrderByDirection.DESC
588
- }
600
+ direction: src_1.OrderByDirection.DESC,
601
+ },
589
602
  ]);
590
- });
591
- it('The case sensitivity of the orderBy *value* is kept', async () => {
592
- await send(`/?orderBy=-NAME`);
603
+ }));
604
+ it('The case sensitivity of the orderBy *value* is kept', () => __awaiter(void 0, void 0, void 0, function* () {
605
+ yield send(`/?orderBy=-NAME`);
593
606
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
594
607
  chai_1.assert.deepEqual(orderBys, [
595
608
  {
596
609
  key: 'NAME',
597
- direction: src_1.OrderByDirection.DESC
598
- }
610
+ direction: src_1.OrderByDirection.DESC,
611
+ },
599
612
  ]);
600
- });
613
+ }));
601
614
  });
602
615
  describe('getOrderBys - Case sensitive', () => {
603
- before(async () => {
616
+ before(() => __awaiter(void 0, void 0, void 0, function* () {
604
617
  (0, testingConfigurations_1.setTestingConfigurations)(true);
605
- await startServer(true);
606
- });
618
+ yield startServer(true);
619
+ }));
607
620
  after(() => {
608
621
  server.close();
609
622
  });
610
- it('The case sensitivity of the "orderBy" key is important', async () => {
611
- await send(`/?ORDERBY=-name`);
623
+ it('The case sensitivity of the "orderBy" key is important', () => __awaiter(void 0, void 0, void 0, function* () {
624
+ yield send(`/?ORDERBY=-name`);
612
625
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
613
626
  chai_1.assert.deepEqual(orderBys, []);
614
- });
615
- it('The case sensitivity of the orderBy *value* is kept', async () => {
616
- await send(`/?orderBy=-NAME`);
627
+ }));
628
+ it('The case sensitivity of the orderBy *value* is kept', () => __awaiter(void 0, void 0, void 0, function* () {
629
+ yield send(`/?orderBy=-NAME`);
617
630
  const orderBys = httpUtils_1.httpUtils.getOrderBys(expressRequest);
618
631
  chai_1.assert.deepEqual(orderBys, [
619
632
  {
620
633
  key: 'NAME',
621
- direction: src_1.OrderByDirection.DESC
622
- }
634
+ direction: src_1.OrderByDirection.DESC,
635
+ },
623
636
  ]);
624
- });
637
+ }));
625
638
  });
626
639
  });
627
640
  });