Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
4447a18e
Commit
4447a18e
authored
Mar 24, 2021
by
Rosanny Sihombing
Browse files
update unit test
parent
344319f5
Changes
1
Show whitespace changes
Inline
Side-by-side
__tests__/gitlab.unit.test.js
View file @
4447a18e
...
...
@@ -31,49 +31,31 @@ 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
)
}
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 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 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 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 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
()
})
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment