Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit 064f465

Browse files
reggeenrmdeuser
authored andcommitted
Feature/1 adjust token expiration logic (#7)
* removed the else block that obtains a access token by using the refresh token #1 * set node version to 12, package-lock should be checked in, updated dependencies #1 * tweaked the jest config to outline test coverage #1 * bumped to the package version to a new release #1
1 parent 632d20f commit 064f465

File tree

6 files changed

+6668
-26
lines changed

6 files changed

+6668
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
package-lock.json
2+
coverage

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- '8'
3+
- '12'
44
deploy:
55
deploy:
66
provider: npm

index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,12 @@ module.exports = class TokenManager {
3232
*/
3333
getToken () {
3434
return new Promise((resolve, reject) => {
35-
if (!this.tokenInfo.access_token || this.isRefreshTokenExpired()) {
36-
// 1. request an initial token
35+
if (!this.tokenInfo.access_token || this.isTokenExpired()) {
36+
// 1. request an initial token or 2. refresh an expired token
3737
return this.requestToken().then(tokenResponse => {
3838
this.saveTokenInfo(tokenResponse)
3939
resolve(this.tokenInfo.access_token)
4040
}).catch(error => reject(error))
41-
} else if (this.isTokenExpired()) {
42-
// 2. refresh a token
43-
return this.refreshToken().then(tokenResponse => {
44-
this.saveTokenInfo(tokenResponse)
45-
resolve(this.tokenInfo.access_token)
46-
}).catch(error => reject(error))
4741
} else {
4842
// 3. use valid managed token
4943
resolve(this.tokenInfo.access_token)

jest.config.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
// clearMocks: false,
1919

2020
// Indicates whether the coverage information should be collected while executing the test
21-
// collectCoverage: false,
21+
collectCoverage: false,
2222

2323
// An array of glob patterns indicating a set of files for which coverage information should be collected
2424
// collectCoverageFrom: null,
@@ -27,23 +27,22 @@ module.exports = {
2727
coverageDirectory: 'coverage',
2828

2929
// An array of regexp pattern strings used to skip coverage collection
30-
// coveragePathIgnorePatterns: [
31-
// "/node_modules/"
32-
// ],
30+
coveragePathIgnorePatterns: [
31+
'/node_modules/',
32+
'/__tests__/'
33+
],
3334

3435
// A list of reporter names that Jest uses when writing coverage reports
35-
// coverageReporters: [
36-
// "json",
37-
// "text",
38-
// "lcov",
39-
// "clover"
40-
// ],
36+
coverageReporters: [
37+
'json',
38+
'text'
39+
],
4140

4241
// An object that configures minimum threshold enforcement for coverage results
4342
// coverageThreshold: null,
4443

4544
// Make calling deprecated APIs throw helpful error messages
46-
// errorOnDeprecated: false,
45+
errorOnDeprecated: true,
4746

4847
// Force coverage collection from ignored files usin a array of glob patterns
4948
// forceCoverageMatch: [],
@@ -124,7 +123,7 @@ module.exports = {
124123
// snapshotSerializers: [],
125124

126125
// The test environment that will be used for testing
127-
testEnvironment: 'node'
126+
testEnvironment: 'node',
128127

129128
// Options that will be passed to the testEnvironment
130129
// testEnvironmentOptions: {},
@@ -170,7 +169,7 @@ module.exports = {
170169
// unmockedModulePathPatterns: undefined,
171170

172171
// Indicates whether each individual test should be reported during the run
173-
// verbose: null,
172+
verbose: false
174173

175174
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
176175
// watchPathIgnorePatterns: [],

0 commit comments

Comments
 (0)