diff --git a/api/__tests__/helper.test.ts b/api/__tests__/helper.test.ts index f7adb2ec2..afa938eb8 100644 --- a/api/__tests__/helper.test.ts +++ b/api/__tests__/helper.test.ts @@ -1,4 +1,5 @@ import 'dotenv/config' +import * as bookcarsTypes from ':bookcars-types' import * as helper from '../src/common/helper' describe('Test string to boolean', () => { @@ -47,3 +48,10 @@ describe('Test getStripeLocale', () => { expect(helper.getStripeLocale('')).toBe('auto') }) }) + +describe('Test validateAccessToken', () => { + it('should test validateAccessToken', async () => { + // test failure + expect(await helper.validateAccessToken('unknown' as bookcarsTypes.SocialSignInType, 'token', 'unknow@unknown.com')).toBeFalsy() + }) +}) diff --git a/api/src/common/helper.ts b/api/src/common/helper.ts index e3ea4064f..9d1c2b1c8 100644 --- a/api/src/common/helper.ts +++ b/api/src/common/helper.ts @@ -226,9 +226,9 @@ export const parseJwt = (token: string) => JSON.parse(Buffer.from(token.split('. * Validate JWT token structure. * * @param {string} token - * @returns {boolean} + * @returns {Promise} */ -export const validateAccessToken = async (socialSignInType: bookcarsTypes.SocialSignInType, token: string, email: string) => { +export const validateAccessToken = async (socialSignInType: bookcarsTypes.SocialSignInType, token: string, email: string): Promise => { if (socialSignInType === bookcarsTypes.SocialSignInType.Facebook) { try { parseJwt(token)