From 7386228218162d332789b796ece345fa63262462 Mon Sep 17 00:00:00 2001 From: Rosanny <rosanny.sihombing@hft-stuttgart.de> Date: Tue, 21 Jun 2022 19:10:07 +0200 Subject: [PATCH] update test --- __test/gitlab.test.ts | 12 ------------ __test/integration.test.ts | 3 +++ __test/methods.test.ts | 16 ---------------- __test/unit.test.ts | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 __test/gitlab.test.ts create mode 100644 __test/integration.test.ts delete mode 100644 __test/methods.test.ts create mode 100644 __test/unit.test.ts diff --git a/__test/gitlab.test.ts b/__test/gitlab.test.ts deleted file mode 100644 index bb18bcd..0000000 --- a/__test/gitlab.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -const gitlab = require('../functions/gitlab') - -describe('GitLab API', () => { - test('get all projects', async () => { - let projects = await gitlab.getProjects(10, 0) - expect(projects).not.toBeNull() - }) - test('get latest pipeline status of a project', async () => { - let status = await gitlab.getLatestPipelineStatus(81) - expect(status).not.toBeNull() - }) -}) \ No newline at end of file diff --git a/__test/integration.test.ts b/__test/integration.test.ts new file mode 100644 index 0000000..daf5f30 --- /dev/null +++ b/__test/integration.test.ts @@ -0,0 +1,3 @@ +test('add 1+1', () => { + expect(1+1).toBe(2) +}) \ No newline at end of file diff --git a/__test/methods.test.ts b/__test/methods.test.ts deleted file mode 100644 index 06dfb06..0000000 --- a/__test/methods.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -const methods = require('../functions/methods') - -describe('DB methods', () => { - test('all mailinglists', async () => { - let lists = await methods.getAllMailinglists(0) - expect(lists).not.toBeNull() - }) - test('project overview', async () => { - let overview = await methods.getProjectOverviewById(81) - expect(overview).not.toBeNull() - }) - test('project images', async () => { - let images = await methods.getProjectImagesById(81) - expect(images).not.toBeNull() - }) -}) \ No newline at end of file diff --git a/__test/unit.test.ts b/__test/unit.test.ts new file mode 100644 index 0000000..a3b4976 --- /dev/null +++ b/__test/unit.test.ts @@ -0,0 +1,18 @@ +import helpers from '../utils/helpers' +import gitlab from '../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)).toBeUndefined +}) \ No newline at end of file -- GitLab