-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
abstract-grant-type_test.js
47 lines (40 loc) 路 1.46 KB
/
abstract-grant-type_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
'use strict';
/**
* Module dependencies.
*/
var AbstractGrantType = require('../../../lib/grant-types/abstract-grant-type');
var sinon = require('sinon');
var should = require('chai').should();
/**
* Test `AbstractGrantType`.
*/
describe('AbstractGrantType', function() {
describe('generateAccessToken()', function() {
it('should call `model.generateAccessToken()`', function() {
var model = {
generateAccessToken: sinon.stub().returns({ client: {}, expiresAt: new Date(), user: {} })
};
var handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model });
return handler.generateAccessToken()
.then(function() {
model.generateAccessToken.callCount.should.equal(1);
model.generateAccessToken.firstCall.thisValue.should.equal(model);
})
.catch(should.fail);
});
});
describe('generateRefreshToken()', function() {
it('should call `model.generateRefreshToken()`', function() {
var model = {
generateRefreshToken: sinon.stub().returns({ client: {}, expiresAt: new Date(new Date() / 2), user: {} })
};
var handler = new AbstractGrantType({ accessTokenLifetime: 120, model: model });
return handler.generateRefreshToken()
.then(function() {
model.generateRefreshToken.callCount.should.equal(1);
model.generateRefreshToken.firstCall.thisValue.should.equal(model);
})
.catch(should.fail);
});
});
});