Skip to content

Commit

Permalink
Update helper.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Dec 14, 2024
1 parent fb931ea commit c8b5a34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api/__tests__/helper.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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', '[email protected]')).toBeFalsy()
})
})
4 changes: 2 additions & 2 deletions api/src/common/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>}
*/
export const validateAccessToken = async (socialSignInType: bookcarsTypes.SocialSignInType, token: string, email: string) => {
export const validateAccessToken = async (socialSignInType: bookcarsTypes.SocialSignInType, token: string, email: string): Promise<boolean> => {
if (socialSignInType === bookcarsTypes.SocialSignInType.Facebook) {
try {
parseJwt(token)
Expand Down

0 comments on commit c8b5a34

Please sign in to comment.