forked from TeraLogics/passport-auth-token
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the tests to support changes in chai and mocha
- Loading branch information
Showing
12 changed files
with
457 additions
and
439 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea/ | ||
.nyc_output/ | ||
build/ | ||
reports/ | ||
|
||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var chai = require('chai'); | ||
global.chai = require('chai'); | ||
|
||
chai.use(require('chai-passport-strategy')); | ||
global.chai.use(require('chai-passport-strategy')); | ||
|
||
global.expect = chai.expect; |
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 |
---|---|---|
@@ -1,61 +1,59 @@ | ||
/* global describe, it, expect, before */ | ||
|
||
var chai = require('chai') | ||
, Strategy = require('../lib/strategy'); | ||
|
||
|
||
describe('Strategy', function() { | ||
|
||
describe('encountering an error during verification', function() { | ||
var strategy = new Strategy(function(token, done) { | ||
done(new Error('something went wrong')); | ||
}); | ||
|
||
var err; | ||
|
||
before(function(done) { | ||
chai.passport(strategy) | ||
.error(function(e) { | ||
err = e; | ||
done(); | ||
}) | ||
.req(function(req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should error', function() { | ||
expect(err).to.be.an.instanceof(Error); | ||
expect(err.message).to.equal('something went wrong'); | ||
}); | ||
}); | ||
|
||
describe('encountering an exception during verification', function() { | ||
var strategy = new Strategy(function(token, done) { | ||
throw new Error('something went horribly wrong'); | ||
}); | ||
|
||
var err; | ||
|
||
before(function(done) { | ||
chai.passport(strategy) | ||
.error(function(e) { | ||
err = e; | ||
done(); | ||
}) | ||
.req(function(req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should error', function() { | ||
expect(err).to.be.an.instanceof(Error); | ||
expect(err.message).to.equal('something went horribly wrong'); | ||
}); | ||
}); | ||
var Strategy = require('../lib/strategy'); | ||
|
||
describe('Strategy', function () { | ||
|
||
describe('encountering an error during verification', function () { | ||
var strategy = new Strategy(function (token, done) { | ||
done(new Error('something went wrong')); | ||
}); | ||
|
||
var err; | ||
|
||
before(function (done) { | ||
chai.passport.use(strategy) | ||
.error(function (e) { | ||
err = e; | ||
done(); | ||
}) | ||
.req(function (req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should error', function () { | ||
expect(err).to.be.an.instanceof(Error); | ||
expect(err.message).to.equal('something went wrong'); | ||
}); | ||
}); | ||
|
||
describe('encountering an exception during verification', function () { | ||
var strategy = new Strategy(function (token, done) { | ||
throw new Error('something went horribly wrong'); | ||
}); | ||
|
||
var err; | ||
|
||
before(function (done) { | ||
chai.passport.use(strategy) | ||
.error(function (e) { | ||
err = e; | ||
done(); | ||
}) | ||
.req(function (req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should error', function () { | ||
expect(err).to.be.an.instanceof(Error); | ||
expect(err.message).to.equal('something went horribly wrong'); | ||
}); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
@@ -1,61 +1,59 @@ | ||
/* global describe, it, expect, before */ | ||
/* jshint expr: true */ | ||
|
||
var chai = require('chai') | ||
, Strategy = require('../lib/strategy'); | ||
|
||
|
||
describe('Strategy', function() { | ||
|
||
describe('failing authentication', function() { | ||
var strategy = new Strategy(function(token, done) { | ||
return done(null, false); | ||
}); | ||
|
||
var info; | ||
|
||
before(function(done) { | ||
chai.passport(strategy) | ||
.fail(function(i) { | ||
info = i; | ||
done(); | ||
}) | ||
.req(function(req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should fail', function() { | ||
expect(info).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('failing authentication with info', function() { | ||
var strategy = new Strategy(function(token, done) { | ||
return done(null, false, { message: 'authentication failed' }); | ||
}); | ||
|
||
var info; | ||
|
||
before(function(done) { | ||
chai.passport(strategy) | ||
.fail(function(i) { | ||
info = i; | ||
done(); | ||
}) | ||
.req(function(req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should fail', function() { | ||
expect(info).to.be.an('object'); | ||
expect(info.message).to.equal('authentication failed'); | ||
}); | ||
}); | ||
var Strategy = require('../lib/strategy'); | ||
|
||
describe('Strategy', function () { | ||
|
||
describe('failing authentication', function () { | ||
var strategy = new Strategy(function (token, done) { | ||
return done(null, false); | ||
}); | ||
|
||
var info; | ||
|
||
before(function (done) { | ||
chai.passport.use(strategy) | ||
.fail(function (i) { | ||
info = i; | ||
done(); | ||
}) | ||
.req(function (req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should fail', function () { | ||
expect(info).to.be.undefined; | ||
}); | ||
}); | ||
|
||
describe('failing authentication with info', function () { | ||
var strategy = new Strategy(function (token, done) { | ||
return done(null, false, { message: 'authentication failed' }); | ||
}); | ||
|
||
var info; | ||
|
||
before(function (done) { | ||
chai.passport.use(strategy) | ||
.fail(function (i) { | ||
info = i; | ||
done(); | ||
}) | ||
.req(function (req) { | ||
req.body = {}; | ||
req.body.token = 'abcdefghijklmnopqrstuvwxyz'; | ||
}) | ||
.authenticate(); | ||
}); | ||
|
||
it('should fail', function () { | ||
expect(info).to.be.an('object'); | ||
expect(info.message).to.equal('authentication failed'); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.