From cc7606c8eefb0a681db161c11351398c9507779c Mon Sep 17 00:00:00 2001 From: Jared Hanson Date: Thu, 19 May 2022 06:52:24 -0700 Subject: [PATCH] Add tests. --- test/http/request.test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/http/request.test.js b/test/http/request.test.js index c845ed8e..eb2d8436 100644 --- a/test/http/request.test.js +++ b/test/http/request.test.js @@ -525,6 +525,36 @@ describe('http.ServerRequest', function() { }); }); + describe('existing session, without passport.initialize() middleware, and invoked with a callback', function() { + var req = new Object(); + req.logout = request.logout; + req.isAuthenticated = request.isAuthenticated; + req.isUnauthenticated = request.isUnauthenticated; + req.user = { id: '1', username: 'root' }; + + var error; + + before(function(done) { + req.logout(function(err) { + error = err; + done(); + }); + }); + + it('should not error', function() { + expect(error).to.be.undefined; + }); + + it('should not be authenticated', function() { + expect(req.isAuthenticated()).to.be.false; + expect(req.isUnauthenticated()).to.be.true; + }); + + it('should clear user', function() { + expect(req.user).to.be.null; + }); + }); + describe('existing session, but not passing a callback argument', function() { var passport = new Passport(); passport.serializeUser(function(user, done) {