-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathstrategy.normal.test.js
68 lines (55 loc) · 1.42 KB
/
strategy.normal.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
59
60
61
62
63
64
65
66
67
68
/* global describe, it, expect, before */
/* jshint expr: true */
var chai = require('chai'),
Strategy = require('../lib/strategy');
describe('Strategy', function () {
describe('handling a request with valid credentials in query', function () {
var strategy = new Strategy(function (req, done) {
return done(null, { id: '1234' }, { scope: 'read' });
});
var user
, info;
before(function (done) {
chai.passport(strategy)
.success(function (u, i) {
user = u;
info = i;
done();
})
.req(function (req) {
req.query = {};
})
.authenticate();
});
it('should supply user', function () {
expect(user).to.be.an.object;
expect(user.id).to.equal('1234');
});
it('should supply info', function () {
expect(info).to.be.an.object;
expect(info.scope).to.equal('read');
});
});
describe('calling back with options', function () {
var optionsPassed;
var strategy = new Strategy(function (req, options, done) {
optionsPassed = options;
return done(null, { id: '1234' }, { scope: 'read' });
});
var options = { 'a': 'b' };
before(function (done) {
chai.passport(strategy)
.success(function (u, i) {
done();
})
.req(function (req) {
req.query = { };
})
.authenticate(options);
});
it('should pass options', function () {
expect(optionsPassed).to.be.an.object;
expect(optionsPassed).to.equal(options);
});
});
});