-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mai/fix 350 bug leagues page stuck in loading st #362
Mai/fix 350 bug leagues page stuck in loading st #362
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Gridiron Survivor Application
Project name: Gridiron Survivor Application
Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.
|
@@ -9,6 +12,9 @@ const createJestConfig = nextJest({ | |||
// Add any custom config to be passed to Jest | |||
const config: Config = { | |||
coverageProvider: 'v8', | |||
moduleNameMapper: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added because when I writing down the path jest.mock('@utils/utils')
, it didn't recognize the file path and I had to use jest.mock('../../../utils/utils')
.
@@ -69,7 +69,9 @@ const Leagues = (): JSX.Element => { | |||
)) | |||
) : ( | |||
<div className="text-center"> | |||
<p className="text-lg font-bold">Loading ...</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We will need to look into Suspense in another ticket.
app/league/all/page.test.tsx
Outdated
|
||
describe('Leagues Component', () => { | ||
const mockUser = { id: '123', leagues: [] }; | ||
const mockUseDataStore = require('@/store/dataStore').useDataStore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is mocking the function like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the test more accessible, but let me take a look to revise them.
app/league/all/page.test.tsx
Outdated
const mockGetGameWeek = require('@/api/apiFunctions').getGameWeek; | ||
|
||
beforeEach(() => { | ||
mockUseDataStore.mockReturnValue({ user: mockUser }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of returning the data here, the mock on line 5 should return this as the default. Then, if you need to override the return, the individual test can do that.
fix #350 1) updated `Loading....` to `You are not enrolled in any leagues` 2) Added unit test to test message is stated if a user is not signed up to a league 3) updated wrapper module so when writing ```js jest.mock('../../utils/utils') ``` can be ```js jest.mock('@utils/utils') ``` <img width="821" alt="image" src="https://github.com/LetsGetTechnical/gridiron-survivor/assets/100221733/e707c2ab-d270-48b4-b185-99f37fea7b3a"> Test passing: <img width="1109" alt="image" src="https://github.com/LetsGetTechnical/gridiron-survivor/assets/100221733/ba688e94-efff-4e78-ae75-ebb8a1385f10"> --------- Co-authored-by: Shashi Lo <[email protected]>
fix #350
Loading....
toYou are not enrolled in any leagues
can be
Test passing: