-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathstrategy.error.test.js
58 lines (47 loc) · 1.2 KB
/
strategy.error.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 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 (req, 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 = {};
})
.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 (req, 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 = {};
})
.authenticate();
});
it('should error', function () {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.equal('something went horribly wrong');
});
});
});