diff --git a/__test/integration.test.ts b/__test/integration.test.ts index daf5f30479680418940430e34ab88a30464b4e77..8de62c7fb08aa2e41e882676a7fb94757b703906 100644 --- a/__test/integration.test.ts +++ b/__test/integration.test.ts @@ -1,3 +1,40 @@ -test('add 1+1', () => { - expect(1+1).toBe(2) +import request from 'supertest' +const express = require('express'); + +const app = express(); +app.set('port', 8888) + +describe('Test endpoint(s)', () => { + it('should return a 200 status code', async () => { + request(app) + .get('/mailinglists') + .expect(200) + .end(function(err, res) { + if (err) throw err; + }); + }); + it('should return a 200 status code', async () => { + request(app) + .get('/projektdaten') + .expect(200) + .end(function(err, res) { + if (err) throw err; + }); + }); + it('should return a 200 status code', async () => { + request(app) + .get('/projektinformationen') + .expect(200) + .end(function(err, res) { + if (err) throw err; + }); + }); + it('should return a 200 status code', async () => { + request(app) + .get('/projectoverview?projectID=1') + .expect(200) + .end(function(err, res) { + if (err) throw err; + }); + }); }) \ No newline at end of file diff --git a/__test/unit.test.ts b/__test/unit.test.ts index 55e3912ef4fb4c1c671aa5a159da41c2e58f3632..b65c0edb94ffd9e16aecf82f0b3deb29628ddba0 100644 --- a/__test/unit.test.ts +++ b/__test/unit.test.ts @@ -1,5 +1,5 @@ -import helpers from '../src/utils/helpers' -import gitlab from '../src/controller/gitlab' +import {helpers} from '../src/utils/helpers' +import {gitlab} from '../src/controller/gitlab' test('[/utils/helpers] convert string to array', () => { expect(helpers.stringToArray('foo')).toStrictEqual(["foo"]) @@ -14,5 +14,5 @@ test('[/controller/gitlab] get projects from gitlab', async () => { test('[/controller/gitlab] get latest pipeline status from gitlab', async () => { expect(await gitlab.getLatestPipelineStatus(97)).toBe("success") - expect(await gitlab.getLatestPipelineStatus(0)).toBeUndefined + expect(await gitlab.getLatestPipelineStatus(0)).toBeFalsy }) \ No newline at end of file diff --git a/src/controller/controller.ts b/src/controller/controller.ts index 6c23f36225d19dfd6a30a637e6fe5e92b8a07f53..61faa6943f269fccac2beefadb8ca68dc63becff 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -1,7 +1,7 @@ import https from 'https' -import {helpers} from '../utils/helpers' -import {gitlab} from './gitlab' -import {dbconn} from '../config/dbconn' +import { helpers } from '../utils/helpers' +import { gitlab } from './gitlab' +import { dbconn } from '../config/dbconn' const lang = 'DE' @@ -239,4 +239,4 @@ const controller = { } } -export {controller} +export { controller } diff --git a/src/controller/gitlab.ts b/src/controller/gitlab.ts index e5369644b9dbb84838c880d337908f0bf6bd9cb1..59e78319e373e19b67a4388d5e6e9c905115e1ea 100644 --- a/src/controller/gitlab.ts +++ b/src/controller/gitlab.ts @@ -37,8 +37,8 @@ const gitlab = { url: 'https://transfer.hft-stuttgart.de/gitlab/api/v4/projects/' + String(projectId) + '/pipelines' }) .then(res => res.data[0].status) - .catch(err => console.error(err)) + .catch(err => console.error(err.response)) } } -export {gitlab} +export { gitlab } diff --git a/src/routes/project.ts b/src/routes/project.ts index e058933df45a452fad0e0d46823af5ed27dfad8f..5801947f599222f17753530be160ada76e59bc94 100644 --- a/src/routes/project.ts +++ b/src/routes/project.ts @@ -1,7 +1,7 @@ -import {controller} from '../controller/controller' +import { controller } from '../controller/controller' module.exports = function (app: any) { - // ======== APP ROUTES - PROJECT ==================== +// ======== APP ROUTES - PROJECT ==================== app.get('/', function (req: any, res: any) { controller.showHome(res) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 238ec54b535c2842c6d1efb4d022f6635109ae12..248382b8fa07018e7c309f62e20c3f9cb4c0b45c 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -5,4 +5,4 @@ const helpers = { } } -export {helpers} +export { helpers }