Commit 4447a18e authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

update unit test

parent 344319f5
...@@ -31,49 +31,31 @@ describe('GitLab API', () => { ...@@ -31,49 +31,31 @@ describe('GitLab API', () => {
}) })
*/ */
it('returns an existing gitlab-userID by an email address', done => { test('returns an existing gitlab user by an email address', async () => {
gitlab.getUserIdByEmail('rosanny.sihombing@hft-stuttgart.de', function(data){ let user = await gitlab.getUserByEmail('putavaliduseremailaddress@here.com')
try { expect(user).not.toBeNull()
expect(data.error).toBeFalsy()
expect(data.data).not.toBeNull()
done()
} catch (error) {
done(error)
}
}) })
test('returns an undefined user', async () => {
let user = await gitlab.getUserByEmail('johndoe@nowhere.com')
expect(user).toBeUndefined()
}) })
it('returns an error due to the non-exist user', done => { test('returns users project', async () => {
gitlab.getUserIdByEmail('test@hft-stuttgart.com', function (data) { let userProjects = await gitlab.getUserProjects('put a valid user id in integer here')
try { expect(userProjects).toBeDefined()
expect(data.error).toBeTruthy()
done()
} catch (error) {
done(error)
}
}) })
test('returns undefined projects, due to non-existing gitlab user ID', async () => {
let userProjects = await gitlab.getUserProjects(0)
expect(userProjects).toBeUndefined()
}) })
it('returns the projects of a particular userId', done => { test('returns a project by ID', async () => {
gitlab.getUserProjects(3, function (data) { let project = await gitlab.getProjectById(13) // m4lab_landing_page
try { expect(project).toBeDefined()
expect(data.error).toBeFalsy()
expect(data.data).not.toBeNull()
done()
} catch (error) {
done(error)
}
}) })
test('returns undefined, due to invalid project ID', async () => {
let project = await gitlab.getProjectById(0)
expect(project).toBeUndefined()
}) })
it('returns an error due to the wrong userID', done => {
gitlab.getUserProjects('abc', function (data) {
try {
expect(data.error).toBeTruthy()
done()
} catch (error) {
done(error)
}
})
})
}) })
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment