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', () => {
...
@@ -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
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