Skip to content

Commit

Permalink
Port test cases to mocha.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Jan 23, 2014
1 parent 270c6f4 commit 8d93fc0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/http/request-test.js
Expand Up @@ -312,6 +312,7 @@ vows.describe('HttpServerRequest').addBatch({
},
},

// OK
'request with a user': {
topic: function() {
var req = new http.IncomingMessage();
Expand All @@ -329,6 +330,7 @@ vows.describe('HttpServerRequest').addBatch({
},
},

// OK
'request with a user stored in a custom user property': {
topic: function() {
var req = new http.IncomingMessage();
Expand All @@ -350,6 +352,7 @@ vows.describe('HttpServerRequest').addBatch({
},
},

// OK
'request without a user': {
topic: function() {
var req = new http.IncomingMessage();
Expand All @@ -366,6 +369,7 @@ vows.describe('HttpServerRequest').addBatch({
},
},

// OK
'request with a null user': {
topic: function() {
var req = new http.IncomingMessage();
Expand Down
47 changes: 47 additions & 0 deletions test/http/request.test.js
Expand Up @@ -330,4 +330,51 @@ describe('http.ServerRequest', function() {

});


describe('#isAuthenticated', function() {

describe('with a user', function() {
var req = new http.IncomingMessage();
req.user = { id: '1', username: 'root' };

it('should be authenticated', function() {
expect(req.isAuthenticated()).to.be.true;
expect(req.isUnauthenticated()).to.be.false;
});
});

describe('with a user set on custom property', function() {
var req = new http.IncomingMessage();
req.currentUser = { id: '1', username: 'root' };
req._passport = {};
req._passport.instance = {};
req._passport.instance._userProperty = 'currentUser';

it('should be authenticated', function() {
expect(req.isAuthenticated()).to.be.true;
expect(req.isUnauthenticated()).to.be.false;
});
});

describe('without a user', function() {
var req = new http.IncomingMessage();

it('should not be authenticated', function() {
expect(req.isAuthenticated()).to.be.false;
expect(req.isUnauthenticated()).to.be.true;
});
});

describe('with a null user', function() {
var req = new http.IncomingMessage();
req.user = null;

it('should not be authenticated', function() {
expect(req.isAuthenticated()).to.be.false;
expect(req.isUnauthenticated()).to.be.true;
});
});

});

});

0 comments on commit 8d93fc0

Please sign in to comment.