gitlab.unit.test.js 1.12 KB
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
const gc = require('../src/controller/gitlabController')
Rosanny Sihombing's avatar
Rosanny Sihombing committed
2

Rosanny Sihombing's avatar
Rosanny Sihombing committed
3
describe('GitLab API', () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
4
  test('returns an existing gitlab user by an email address', async () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
5
    const user = await gc.gitlabController.getUserByEmail('litehon958@whipjoy.com')
Rosanny Sihombing's avatar
Rosanny Sihombing committed
6
7
8
    expect(user).not.toBeNull()
  })
  test('returns an undefined user', async () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
9
    const user = await gc.gitlabController.getUserByEmail('johndoe@nowhere.com')
Rosanny Sihombing's avatar
Rosanny Sihombing committed
10
    expect(user).toBeUndefined()
Rosanny Sihombing's avatar
Rosanny Sihombing committed
11
  })
Rosanny Sihombing's avatar
Rosanny Sihombing committed
12

Rosanny Sihombing's avatar
Rosanny Sihombing committed
13
  test('returns users project', async () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
14
    const userProjects = await gc.gitlabController.getUserProjects(136)
Rosanny Sihombing's avatar
Rosanny Sihombing committed
15
16
    expect(userProjects).toBeDefined()
  })
Rosanny Sihombing's avatar
Rosanny Sihombing committed
17
18
19
  test('returns null, due to non-existing gitlab user ID', async () => {
    const userProjects = await gc.gitlabController.getUserProjects(0)
    expect(userProjects).toBeNull()
Rosanny Sihombing's avatar
Rosanny Sihombing committed
20
  })
Rosanny Sihombing's avatar
Rosanny Sihombing committed
21

Rosanny Sihombing's avatar
Rosanny Sihombing committed
22
  test('returns a project by ID', async () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
23
    const project = await gc.gitlabController.getProjectById(13) // m4lab_landing_page
Rosanny Sihombing's avatar
Rosanny Sihombing committed
24
25
26
    expect(project).toBeDefined()
  })
  test('returns undefined, due to invalid project ID', async () => {
Rosanny Sihombing's avatar
Rosanny Sihombing committed
27
28
    const project = await gc.gitlabController.getProjectById(0)
    expect(project).toBeNull()
Rosanny Sihombing's avatar
Rosanny Sihombing committed
29
  })
Rosanny Sihombing's avatar
Rosanny Sihombing committed
30
})