Skip to content

Commit

Permalink
Fix unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Nov 9, 2015
1 parent e62afe0 commit 6909b22
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/http/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
/* jshint expr: true */

var http = require('http')
, Passport = require('../..').Passport;
, Passport = require('../..').Passport
, IncomingMessageExt = require('../../lib/http/request');

require('../../lib/http/request');
require('../../lib/framework/connect').__monkeypatchNode();


describe('http.ServerRequest', function() {

describe('prototoype', function() {
var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req.logIn = IncomingMessageExt.logIn;
req.logout = IncomingMessageExt.logout;
req.logOut = IncomingMessageExt.logOut;
req.isAuthenticated = IncomingMessageExt.isAuthenticated;
req.isUnauthenticated = IncomingMessageExt.isUnauthenticated;

it('should be extended with login', function() {
expect(req.login).to.be.an('function');
Expand All @@ -37,6 +44,7 @@ describe('http.ServerRequest', function() {
var passport = new Passport();

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand Down Expand Up @@ -77,6 +85,7 @@ describe('http.ServerRequest', function() {
passport._userProperty = 'currentUser';

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand Down Expand Up @@ -120,6 +129,7 @@ describe('http.ServerRequest', function() {
var passport = new Passport();

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand All @@ -145,6 +155,7 @@ describe('http.ServerRequest', function() {

describe('not establishing a session, without passport.initialize() middleware', function() {
var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;

var error;

Expand Down Expand Up @@ -180,6 +191,7 @@ describe('http.ServerRequest', function() {
});

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand Down Expand Up @@ -223,6 +235,7 @@ describe('http.ServerRequest', function() {
passport._userProperty = 'currentUser';

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand Down Expand Up @@ -269,6 +282,7 @@ describe('http.ServerRequest', function() {
});

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand Down Expand Up @@ -305,6 +319,7 @@ describe('http.ServerRequest', function() {

describe('establishing a session, without passport.initialize() middleware', function() {
var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
var user = { id: '1', username: 'root' };

it('should throw an exception', function() {
Expand All @@ -321,6 +336,7 @@ describe('http.ServerRequest', function() {
});

var req = new http.IncomingMessage();
req.login = IncomingMessageExt.login;
req._passport = {};
req._passport.instance = passport;
req._passport.session = {};
Expand All @@ -343,6 +359,7 @@ describe('http.ServerRequest', function() {
var passport = new Passport();

var req = new http.IncomingMessage();
req.logout = IncomingMessageExt.logout;
req.user = { id: '1', username: 'root' };
req._passport = {};
req._passport.instance = passport;
Expand All @@ -369,6 +386,7 @@ describe('http.ServerRequest', function() {
var passport = new Passport();

var req = new http.IncomingMessage();
req.logout = IncomingMessageExt.logout;
req.currentUser = { id: '1', username: 'root' };
req._passport = {};
req._passport.instance = passport;
Expand All @@ -394,6 +412,7 @@ describe('http.ServerRequest', function() {

describe('existing session, without passport.initialize() middleware', function() {
var req = new http.IncomingMessage();
req.logout = IncomingMessageExt.logout;
req.user = { id: '1', username: 'root' };

req.logout();
Expand Down

0 comments on commit 6909b22

Please sign in to comment.