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

update unit test

parent 344319f5
......@@ -30,50 +30,32 @@ describe('GitLab API', () => {
})
})
*/
it('returns an existing gitlab-userID by an email address', done => {
gitlab.getUserIdByEmail('rosanny.sihombing@hft-stuttgart.de', function(data){
try {
expect(data.error).toBeFalsy()
expect(data.data).not.toBeNull()
done()
} catch (error) {
done(error)
}
})
})
it('returns an error due to the non-exist user', done => {
gitlab.getUserIdByEmail('test@hft-stuttgart.com', function (data) {
try {
expect(data.error).toBeTruthy()
done()
} catch (error) {
done(error)
}
})
test('returns an existing gitlab user by an email address', async () => {
let user = await gitlab.getUserByEmail('putavaliduseremailaddress@here.com')
expect(user).not.toBeNull()
})
test('returns an undefined user', async () => {
let user = await gitlab.getUserByEmail('johndoe@nowhere.com')
expect(user).toBeUndefined()
})
it('returns the projects of a particular userId', done => {
gitlab.getUserProjects(3, function (data) {
try {
expect(data.error).toBeFalsy()
expect(data.data).not.toBeNull()
done()
} catch (error) {
done(error)
}
})
test('returns users project', async () => {
let userProjects = await gitlab.getUserProjects('put a valid user id in integer here')
expect(userProjects).toBeDefined()
})
test('returns undefined projects, due to non-existing gitlab user ID', async () => {
let userProjects = await gitlab.getUserProjects(0)
expect(userProjects).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)
}
})
test('returns a project by ID', async () => {
let project = await gitlab.getProjectById(13) // m4lab_landing_page
expect(project).toBeDefined()
})
test('returns undefined, due to invalid project ID', async () => {
let project = await gitlab.getProjectById(0)
expect(project).toBeUndefined()
})
})
\ 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