Skip to content

Commit e1fdc23

Browse files
committed
fix(tests): replace Promise. calls with native async behaviour where applicable
1 parent 2563e7b commit e1fdc23

8 files changed

+30
-30
lines changed

test/integration/grant-types/abstract-grant-type_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ describe('AbstractGrantType integration', function() {
7070

7171
it('should support promises', function() {
7272
const model = {
73-
generateAccessToken: function() {
74-
return Promise.resolve({});
73+
generateAccessToken: async function() {
74+
return {};
7575
}
7676
};
7777
const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 });
@@ -104,8 +104,8 @@ describe('AbstractGrantType integration', function() {
104104

105105
it('should support promises', function() {
106106
const model = {
107-
generateRefreshToken: function() {
108-
return Promise.resolve({});
107+
generateRefreshToken: async function() {
108+
return {};
109109
}
110110
};
111111
const handler = new AbstractGrantType({ accessTokenLifetime: 123, model: model, refreshTokenLifetime: 456 });

test/integration/grant-types/authorization-code-grant-type_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('AuthorizationCodeGrantType integration', function() {
145145
it('should support promises', function() {
146146
const client = { id: 'foobar' };
147147
const model = {
148-
getAuthorizationCode: function() { return Promise.resolve({ authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }); },
148+
getAuthorizationCode: function() { return { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} }; },
149149
revokeAuthorizationCode: function() { return true; },
150150
saveToken: function() {}
151151
};
@@ -362,7 +362,7 @@ describe('AuthorizationCodeGrantType integration', function() {
362362
const authorizationCode = { authorizationCode: 12345, client: { id: 'foobar' }, expiresAt: new Date(new Date() * 2), user: {} };
363363
const client = { id: 'foobar' };
364364
const model = {
365-
getAuthorizationCode: function() { return Promise.resolve(authorizationCode); },
365+
getAuthorizationCode: async function() { return authorizationCode; },
366366
revokeAuthorizationCode: function() {},
367367
saveToken: function() {}
368368
};
@@ -469,7 +469,7 @@ describe('AuthorizationCodeGrantType integration', function() {
469469
const authorizationCode = { authorizationCode: 12345, client: {}, expiresAt: new Date(new Date() / 2), user: {} };
470470
const model = {
471471
getAuthorizationCode: function() {},
472-
revokeAuthorizationCode: function() { return Promise.resolve(true); },
472+
revokeAuthorizationCode: async function() { return true; },
473473
saveToken: function() {}
474474
};
475475
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
@@ -513,7 +513,7 @@ describe('AuthorizationCodeGrantType integration', function() {
513513
const model = {
514514
getAuthorizationCode: function() {},
515515
revokeAuthorizationCode: function() {},
516-
saveToken: function() { return Promise.resolve(token); }
516+
saveToken: async function() { return token; }
517517
};
518518
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
519519

test/integration/grant-types/client-credentials-grant-type_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ describe('ClientCredentialsGrantType integration', function() {
168168
it('should support promises', function() {
169169
const user = { email: 'foo@bar.com' };
170170
const model = {
171-
getUserFromClient: function() { return Promise.resolve(user); },
171+
getUserFromClient: async function() { return user; },
172172
saveToken: function() {}
173173
};
174174
const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 120, model: model });
@@ -211,7 +211,7 @@ describe('ClientCredentialsGrantType integration', function() {
211211
const token = {};
212212
const model = {
213213
getUserFromClient: function() {},
214-
saveToken: function() { return Promise.resolve(token); }
214+
saveToken: async function() { return token; }
215215
};
216216
const grantType = new ClientCredentialsGrantType({ accessTokenLifetime: 123, model: model });
217217

test/integration/grant-types/password-grant-type_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('PasswordGrantType integration', function() {
113113
const token = {};
114114
const model = {
115115
getUser: function() { return {}; },
116-
saveToken: function() { return Promise.resolve(token); }
116+
saveToken: async function() { return token; }
117117
};
118118
const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model });
119119
const request = new Request({ body: { username: 'foo', password: 'bar' }, headers: {}, method: {}, query: {} });
@@ -245,7 +245,7 @@ describe('PasswordGrantType integration', function() {
245245
it('should support promises', function() {
246246
const user = { email: 'foo@bar.com' };
247247
const model = {
248-
getUser: function() { return Promise.resolve(user); },
248+
getUser: async function() { return user; },
249249
saveToken: function() {}
250250
};
251251
const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model });
@@ -288,7 +288,7 @@ describe('PasswordGrantType integration', function() {
288288
const token = {};
289289
const model = {
290290
getUser: function() {},
291-
saveToken: function() { return Promise.resolve(token); }
291+
saveToken: async function() { return token; }
292292
};
293293
const grantType = new PasswordGrantType({ accessTokenLifetime: 123, model: model });
294294

test/integration/grant-types/refresh-token-grant-type_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ describe('RefreshTokenGrantType integration', function() {
131131
it('should support promises', function() {
132132
const client = { id: 123 };
133133
const model = {
134-
getRefreshToken: function() { return Promise.resolve({ accessToken: 'foo', client: { id: 123 }, user: {} }); },
135-
revokeToken: function() { return Promise.resolve({ accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }); },
136-
saveToken: function() { return Promise.resolve({ accessToken: 'foo', client: {}, user: {} }); }
134+
getRefreshToken: async function() { return { accessToken: 'foo', client: { id: 123 }, user: {} }; },
135+
revokeToken: async function() { return { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} }; },
136+
saveToken: async function() { return { accessToken: 'foo', client: {}, user: {} }; }
137137
};
138138
const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model });
139139
const request = new Request({ body: { refresh_token: 'foobar' }, headers: {}, method: {}, query: {} });
@@ -357,7 +357,7 @@ describe('RefreshTokenGrantType integration', function() {
357357
const client = { id: 123 };
358358
const token = { accessToken: 'foo', client: { id: 123 }, user: {} };
359359
const model = {
360-
getRefreshToken: function() { return Promise.resolve(token); },
360+
getRefreshToken: async function() { return token; },
361361
revokeToken: function() {},
362362
saveToken: function() {}
363363
};
@@ -419,7 +419,7 @@ describe('RefreshTokenGrantType integration', function() {
419419
const token = { accessToken: 'foo', client: {}, refreshTokenExpiresAt: new Date(new Date() / 2), user: {} };
420420
const model = {
421421
getRefreshToken: function() {},
422-
revokeToken: function() { return Promise.resolve(token); },
422+
revokeToken: async function() { return token; },
423423
saveToken: function() {}
424424
};
425425
const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model });
@@ -462,7 +462,7 @@ describe('RefreshTokenGrantType integration', function() {
462462
const model = {
463463
getRefreshToken: function() {},
464464
revokeToken: function() {},
465-
saveToken: function() { return Promise.resolve(token); }
465+
saveToken: async function() { return token; }
466466
};
467467
const grantType = new RefreshTokenGrantType({ accessTokenLifetime: 123, model: model });
468468

test/integration/handlers/authenticate-handler_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ describe('AuthenticateHandler integration', function() {
445445

446446
it('should support promises', function() {
447447
const model = {
448-
getAccessToken: function() {
449-
return Promise.resolve({ user: {} });
448+
getAccessToken: async function() {
449+
return { user: {} };
450450
}
451451
};
452452
const handler = new AuthenticateHandler({ model: model });

test/integration/handlers/authorize-handler_test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,8 @@ describe('AuthorizeHandler integration', function() {
612612

613613
it('should support promises', function() {
614614
const model = {
615-
generateAuthorizationCode: function() {
616-
return Promise.resolve({});
615+
generateAuthorizationCode: async function() {
616+
return {};
617617
},
618618
getAccessToken: function() {},
619619
getClient: function() {},
@@ -670,8 +670,8 @@ describe('AuthorizeHandler integration', function() {
670670
getAccessToken: function() {},
671671
getClient: function() {},
672672
saveAuthorizationCode: function() {},
673-
validateRedirectUri: function() {
674-
return Promise.resolve(true);
673+
validateRedirectUri: async function() {
674+
return true;
675675
}
676676
};
677677

@@ -848,8 +848,8 @@ describe('AuthorizeHandler integration', function() {
848848
it('should support promises', function() {
849849
const model = {
850850
getAccessToken: function() {},
851-
getClient: function() {
852-
return Promise.resolve({ grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] });
851+
getClient: async function() {
852+
return { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
853853
},
854854
saveAuthorizationCode: function() {}
855855
};
@@ -1100,8 +1100,8 @@ describe('AuthorizeHandler integration', function() {
11001100
const model = {
11011101
getAccessToken: function() {},
11021102
getClient: function() {},
1103-
saveAuthorizationCode: function() {
1104-
return Promise.resolve({});
1103+
saveAuthorizationCode: async function() {
1104+
return {};
11051105
}
11061106
};
11071107
const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });

test/integration/handlers/token-handler_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ describe('TokenHandler integration', function() {
587587

588588
it('should support promises', function() {
589589
const model = {
590-
getClient: function() { return Promise.resolve({ grants: [] }); },
590+
getClient: async function() { return { grants: [] }; },
591591
saveToken: function() {}
592592
};
593593
const handler = new TokenHandler({ accessTokenLifetime: 120, model: model, refreshTokenLifetime: 120 });

0 commit comments

Comments
 (0)