test: add tests for routes

This commit is contained in:
Jovan Krunić
2020-09-28 11:12:56 +02:00
committed by Rainer Killinger
parent 751693bebc
commit d3955b3cdd
22 changed files with 1315 additions and 455 deletions

View File

@@ -25,7 +25,7 @@ import cors from 'cors';
import {Express} from 'express';
import morgan from 'morgan';
import {join} from 'path';
import {configFile, isTestEnvironment, mailer, plugins, validator} from './common';
import {configFile, DEFAULT_TIMEOUT, isTestEnvironment, mailer, plugins, validator} from './common';
import {MailQueue} from './notification/mail-queue';
import {bulkAddRouter} from './routes/bulk-add-route';
import {bulkDoneRouter} from './routes/bulk-done-route';
@@ -53,8 +53,7 @@ export async function configureApp(app: Express) {
integrationTestTimeout = setTimeout(() => {
process.exit(1);
},
// tslint:disable-next-line:no-magic-numbers
20000);
DEFAULT_TIMEOUT);
return false;
}
@@ -95,6 +94,7 @@ export async function configureApp(app: Express) {
// only accept json as content type for all requests
app.use((req, res, next) => {
// get the content type
// TODO: Always lowercase (see type definition of IncomingHttpHeaders)
let contentType = '';
// the content type can be string, string[] or undefined
if (typeof req.headers['Content-Type'] === 'string') {
@@ -189,7 +189,7 @@ export async function configureApp(app: Express) {
throw new Error('No implementation for configured database found. Please check your configuration.');
}
Logger.ok('Validated config file sucessfully');
Logger.ok('Validated config file successfully');
// treats /foo and /foo/ as two different routes
// see http://expressjs.com/en/api.html#app.set