diff --git a/__test/integration.test.js b/__test/integration.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3888d47ec32d8cc68336a8ea8cddc9c970300c84 --- /dev/null +++ b/__test/integration.test.js @@ -0,0 +1,40 @@ +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 + }) + }) +}) diff --git a/__test/integration.test.ts b/__test/integration.test.ts deleted file mode 100644 index 8de62c7fb08aa2e41e882676a7fb94757b703906..0000000000000000000000000000000000000000 --- a/__test/integration.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -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.js b/__test/unit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d1f44d014e7156668b6f16d97ad6063596cec5fa --- /dev/null +++ b/__test/unit.test.js @@ -0,0 +1,18 @@ +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']) + expect(helpers.stringToArray('foo,bar')).toStrictEqual(['foo', 'bar']) + expect(helpers.stringToArray('')).toBeNull + expect(helpers.stringToArray(String(null))).toBeNull +}) + +test('[/controller/gitlab] get projects from gitlab', async () => { + expect(await gitlab.getProjects(100, 0)).not.toBeNull +}) + +test('[/controller/gitlab] get latest pipeline status from gitlab', async () => { + expect(await gitlab.getLatestPipelineStatus(97)).toBe('success') + expect(await gitlab.getLatestPipelineStatus(0)).toBeFalsy +}) diff --git a/__test/unit.test.ts b/__test/unit.test.ts deleted file mode 100644 index b65c0edb94ffd9e16aecf82f0b3deb29628ddba0..0000000000000000000000000000000000000000 --- a/__test/unit.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -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"]) - expect(helpers.stringToArray('foo,bar')).toStrictEqual(["foo","bar"]) - expect(helpers.stringToArray('')).toBeNull - expect(helpers.stringToArray(String(null))).toBeNull -}); - -test('[/controller/gitlab] get projects from gitlab', async () => { - expect(await gitlab.getProjects(100, 0)).not.toBeNull -}) - -test('[/controller/gitlab] get latest pipeline status from gitlab', async () => { - expect(await gitlab.getLatestPipelineStatus(97)).toBe("success") - expect(await gitlab.getLatestPipelineStatus(0)).toBeFalsy -}) \ No newline at end of file