-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #46 added unit test for GET /blog and GET /admin. Setup admin l…
…ogin for unit test.
- Loading branch information
Showing
4 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use strict" | ||
var request = require('supertest'); | ||
var app = require('../index.js'); | ||
|
||
const admin_user = { | ||
email: 'admin@admin.com', | ||
password: 'asdfasdf' | ||
} | ||
|
||
// for storing session | ||
const agent = request.agent(app); | ||
|
||
describe('Admin', function(){ | ||
before(function(done){ | ||
agent | ||
.post('/auth/login') | ||
.send(admin_user) | ||
.expect(302, done) | ||
}) | ||
|
||
describe('GET /admin/', function() { | ||
it('should return 200 OK', function(done) { | ||
agent | ||
.get('/admin/') | ||
.expect(200, done) | ||
}); | ||
it('should return 303 when not admin', function(done){ | ||
request(app) | ||
.get('/admin/') | ||
.expect(302, done) | ||
}) | ||
}); | ||
|
||
describe('GET /admin/users', function(){ | ||
it('should return 200 OK', function(done){ | ||
agent | ||
.get('/admin/users') | ||
.expect(200, done) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters