unit.test.ts 743 Bytes
Newer Older
Rosanny Sihombing's avatar
Rosanny Sihombing committed
1
2
import helpers from '../src/utils/helpers'
import gitlab from '../src/controller/gitlab'
Rosanny Sihombing's avatar
Rosanny Sihombing committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

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
})