forked from jaredhanson/passport-facebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrategy.test.js
67 lines (56 loc) · 1.95 KB
/
strategy.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
var chai = require('chai')
, FacebookStrategy = require('../lib/strategy');
describe('Strategy', function() {
var strategy = new FacebookStrategy({
clientID: 'ABC123',
clientSecret: 'secret'
},
function() {});
it('should be named facebook', function() {
expect(strategy.name).to.equal('facebook');
});
describe('handling a return request in which authorization was denied by user', function() {
var info;
before(function(done) {
chai.passport(strategy)
.fail(function(i) {
info = i;
done();
})
.req(function(req) {
req.query = {};
req.query.error = 'access_denied';
req.query.error_code = '200';
req.query.error_description = 'Permissions error';
req.query.error_reason = 'user_denied';
})
.authenticate();
});
it('should fail with info', function() {
expect(info).to.not.be.undefined;
expect(info.message).to.equal('Permissions error');
});
});
describe('handling a return request in which authorization has failed with an error', function() {
var err;
before(function(done) {
chai.passport(strategy)
.error(function(e) {
err = e;
done();
})
.req(function(req) {
req.query = {};
req.query.error_code = '901';
req.query.error_message = 'This app is in sandbox mode. Edit the app configuration at http://developers.facebook.com/apps to make the app publicly visible.';
})
.authenticate();
});
it('should error', function() {
expect(err.constructor.name).to.equal('FacebookAuthorizationError');
expect(err.message).to.equal('This app is in sandbox mode. Edit the app configuration at http://developers.facebook.com/apps to make the app publicly visible.');
expect(err.code).to.equal(901);
expect(err.status).to.equal(500);
});
});
});