-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a28cbe
commit 7ebc419
Showing
60 changed files
with
1,310 additions
and
750 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('@baseapp-frontend/test/__mocks__/expo.ts') | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('@baseapp-frontend/test/__mocks__/react-native.ts') | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
packages/authentication/modules/user/getUser/__tests__/getUser.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import type { CookiesGetByNameFn } from '@baseapp-frontend/test' | ||
|
||
import Cookies from 'js-cookie' | ||
import { getToken } from '@baseapp-frontend/utils/functions/token/getToken' | ||
|
||
import getUser from '../index' | ||
import jwt from './fixtures/jwt.json' | ||
|
||
jest.mock('@baseapp-frontend/utils/functions/token/getToken', () => ({ | ||
getToken: jest.fn(), | ||
})) | ||
|
||
describe('getUser', () => { | ||
it('should return the user from the JWT cookie', async () => { | ||
;(Cookies.get as CookiesGetByNameFn) = jest.fn(() => jwt.token) | ||
it('should return the user from the JWT token', () => { | ||
;(getToken as jest.Mock).mockReturnValue(jwt.token) | ||
const user = getUser() | ||
|
||
expect(user?.email).toBe('[email protected]') | ||
expect(user?.firstName).toBe('John') | ||
expect(user?.lastName).toBe('Doe') | ||
}) | ||
|
||
it('should return null if the JWT cookie is not set', async () => { | ||
;(Cookies.get as CookiesGetByNameFn) = jest.fn(() => undefined) | ||
it('should return null if no token is set', () => { | ||
;(getToken as jest.Mock).mockReturnValue(undefined) | ||
const user = getUser() | ||
|
||
expect(user).toBeNull() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
packages/authentication/modules/user/getUserAsync/__tests__/getUserAsync.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
import type { CookiesGetByNameFn } from '@baseapp-frontend/test' | ||
|
||
import Cookies from 'js-cookie' | ||
import { getTokenAsync } from '@baseapp-frontend/utils/functions/token/getTokenAsync' | ||
|
||
import getUserAsync from '../index' | ||
import jwt from './fixtures/jwt.json' | ||
|
||
jest.mock('@baseapp-frontend/utils/functions/token/getTokenAsync', () => ({ | ||
getTokenAsync: jest.fn(), | ||
})) | ||
|
||
describe('getUserAsync', () => { | ||
it('should return the user from the JWT cookie', async () => { | ||
;(Cookies.get as CookiesGetByNameFn) = jest.fn(() => jwt.token) | ||
it('should return the user from the JWT token', async () => { | ||
;(getTokenAsync as jest.Mock).mockReturnValue(jwt.token) | ||
|
||
const user = await getUserAsync() | ||
|
||
expect(user?.email).toBe('[email protected]') | ||
expect(user?.firstName).toBe('John') | ||
expect(user?.lastName).toBe('Doe') | ||
}) | ||
|
||
it('should return null if the JWT cookie is not set', async () => { | ||
;(Cookies.get as CookiesGetByNameFn) = jest.fn(() => undefined) | ||
it('should return null if no token is set', async () => { | ||
;(getTokenAsync as jest.Mock).mockReturnValue(undefined) | ||
|
||
const user = await getUserAsync() | ||
|
||
expect(user).toBeNull() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('@baseapp-frontend/test/__mocks__/expo.ts') | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('@baseapp-frontend/test/__mocks__/react-native.ts') | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const ExpoSecureStore = { | ||
getItemAsync: jest.fn(async (key: string) => { | ||
return key === 'ACCESS_KEY_NAME' ? 'mocked_value' : null | ||
}), | ||
setItemAsync: jest.fn(async (key: string, value: string) => { | ||
return true | ||
}), | ||
deleteItemAsync: jest.fn(async (key: string) => { | ||
return true | ||
}), | ||
} | ||
|
||
const Constants = { | ||
expoConfig: { | ||
extra: { | ||
EXPO_PUBLIC_API_BASE_URL: undefined, | ||
EXPO_PUBLIC_RELAY_ENDPOINT: undefined, | ||
EXPO_PUBLIC_WS_RELAY_ENDPOINT: undefined, | ||
}, | ||
}, | ||
} | ||
|
||
module.exports = { | ||
...ExpoSecureStore, | ||
...Constants, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// ignoring react-native imports in tests, we may change this in the future | ||
module.exports = { | ||
Platform: { OS: 'web' }, | ||
} |
Oops, something went wrong.