1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

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

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