diff options
author | Ben Burwell <ben@benburwell.com> | 2015-12-16 22:09:50 -0500 |
---|---|---|
committer | Ben Burwell <ben@benburwell.com> | 2015-12-16 22:09:50 -0500 |
commit | 7636932bc6af6b509269c6adfd620c5283051b3f (patch) | |
tree | 14d8c673c8d16e76e70099f28f55ede41d36c787 /lib | |
parent | b189c8bf0a951b367e610c9941c3aff482a8968e (diff) |
Update unit tests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/clients/refresh.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/clients/refresh.js b/lib/clients/refresh.js index b4a3930..7b9fde7 100644 --- a/lib/clients/refresh.js +++ b/lib/clients/refresh.js @@ -1,4 +1,6 @@ var request = require('request'); +var Timestamp = require('unix-timestamp'); +Timestamp.round = true; var RefreshClient = function(refreshString) { if (typeof refreshString !== 'string') { @@ -6,7 +8,7 @@ var RefreshClient = function(refreshString) { } this._refreshToken = refreshString; this._accessToken = ''; - this._accessTokenExpiration = Math.floor( new Date()/1000 ); + this._accessTokenExpiration = Timestamp.now(-1); }; RefreshClient.prototype._doRequest = function(url) { @@ -47,7 +49,7 @@ RefreshClient.prototype._doRequest = function(url) { RefreshClient.prototype._getAccessToken = function() { var self = this; return new Promise(function(fulfill, reject) { - var currentTime = Math.floor( new Date()/1000 ); + var currentTime = Timestamp.now(); if (self._accessTokenExpiration - currentTime <= 10) { fulfill(self._refreshAccessToken()); } else { |