test: add unit test for whoami referer endpoint

This commit is contained in:
Juan Picado @jotadeveloper 2019-04-28 09:05:31 +02:00
parent 450224dc1f
commit 4242eaa6b8
No known key found for this signature in database
GPG Key ID: 18AC54485952D158
1 changed files with 19 additions and 4 deletions

View File

@ -80,12 +80,27 @@ describe('endpoint unit test', () => {
});
describe('should test whoami api', () => {
test('should test referer /whoami endpoint', (done) => {
request(app)
.get('/whoami')
.set('referer', 'whoami')
.expect(HTTP_STATUS.OK)
.end(done);
});
test('should test no referer /whoami endpoint', (done) => {
request(app)
.get('/whoami')
.expect(HTTP_STATUS.NOT_FOUND)
.end(done);
});
test('should test /-/whoami endpoint', (done) => {
request(app)
.get('/-/whoami')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.OK)
.end(function(err, res) {
.end(function(err) {
if (err) {
return done(err);
}
@ -98,7 +113,7 @@ describe('endpoint unit test', () => {
.get('/-/whoami')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.OK)
.end(function(err, res) {
.end(function(err) {
if (err) {
return done(err);
}