1 | var Strategy = require('../lib/strategy');
|
2 |
|
3 | describe('Strategy', function() {
|
4 | var strategy = new Strategy({jwtFromRequest: function(){}, secretOrKey: 'secret'}, function() {});
|
5 |
|
6 | it('should be named jwt', function() {
|
7 | expect(strategy.name).to.equal('jwt');
|
8 | });
|
9 |
|
10 |
|
11 | it('should throw if constructed without a verify callback', function() {
|
12 | expect(function() {
|
13 | var s = new Strategy({jwtFromRequest: function(r) {}, secretOrKey: 'secret'});
|
14 | }).to.throw(TypeError, "JwtStrategy requires a verify callback");
|
15 | });
|
16 |
|
17 |
|
18 | it('should throw if constructed without a secretOrKey arg', function() {
|
19 | expect(function() {
|
20 | var s = new Strategy({jwtFromRequest: function(r) {}, secretOrKey: null}, function() {});
|
21 | }).to.throw(TypeError, 'JwtStrategy requires a secret or key');
|
22 | });
|
23 |
|
24 |
|
25 | it('should throw if constructed without a jwtFromRequest arg', function() {
|
26 | expect(function() {
|
27 | var s = new Strategy({secretOrKey: 'secret'}, function() {});
|
28 | }).to.throw(TypeError);
|
29 | });
|
30 | });
|