-
Notifications
You must be signed in to change notification settings - Fork 356
Remove withRouter (2/2)
#3009
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
Merged
Merged
Remove withRouter (2/2)
#3009
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d9c8cd7
Enzyme -> RTL Navtabs.test.tsx
taneliang 310e56d
Functionalize Navtabs
taneliang 6ee3f7b
Fix nit in reducer types
taneliang 86a6e08
WIP Enzyme -> RTL ModuleArchiveContainer.test.tsx
taneliang e887abd
Fix ModuleArchiveContainer tests and split retryImport into its own file
taneliang 4b2255d
Mock RandomKawaii to reduce noise in test failure messages
taneliang 3ee467b
Reduce test output noise by mocking react-feather in tests
taneliang b17bc2c
yarn upgrade @types/react-router-dom
taneliang e4f5ae1
Functionalize ModuleArchiveContainer
taneliang 723242a
Enzyme -> RTL ModulePageContainer.test.tsx
taneliang 8522944
Functionalize ModulePageContainer
taneliang d9a32cb
Rename module-list.json -> module-code-map.jsonn
taneliang 2330d57
Overhaul TimetableContainer.test.tsx with RTL
taneliang c771035
Change getModuleCondensed selector to operate on global Redux state
taneliang ee0f59f
Replace getSemesterTimetable with getSemesterTimetable(Colors|Lessons…
taneliang 6eeb745
Functionalize TimetableContainer
taneliang e9c3cea
Merge branch 'master' into eliang/even-more-fc
taneliang c7b9b35
Remove withRouter and matchBreakpoint hocs from VenueDetails
taneliang d464848
import * as React -> import type { FC } in NoFooter
taneliang b7c0613
Clarify VenueDetails useMediaQuery return variable name
taneliang 34e4c87
Merge branch 'master' into eliang/even-more-fc
taneliang 829e6d5
yarn lint:code --fix
taneliang ef77b04
Fix noob mistakes in TimetableContainer RTL tests
taneliang 03c03e3
Add mock Axios response in TimetableContainer
taneliang 9dd20e1
Fix all noob RTL mistakes in this PR
taneliang e0aefaa
Rename renderResult -> view
taneliang 5cd113c
Increase renderWithRouterMatch param flexibility
taneliang ed658e8
Merge branch 'master' into eliang/even-more-fc
taneliang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or 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,17 @@ | ||
| [ | ||
| { "moduleCode": "ACC2002", "title": "Managerial Accounting", "semesters": [1, 2] }, | ||
| { | ||
| "moduleCode": "BFS1001", | ||
| "title": "Personal Development & Career Management", | ||
| "semesters": [1, 2] | ||
| }, | ||
| { "moduleCode": "CS1010S", "title": "Programming Methodology", "semesters": [1, 2] }, | ||
| { | ||
| "moduleCode": "CS3216", | ||
| "title": "Software Product Engineering for Digital Markets", | ||
| "semesters": [1] | ||
| }, | ||
| { "moduleCode": "CS4243", "title": "Computer Vision and Pattern Recognition", "semesters": [1] }, | ||
| { "moduleCode": "GER1000", "title": "Quantitative Reasoning", "semesters": [1, 2] }, | ||
| { "moduleCode": "GES1021", "title": "Natural Heritage of Singapore", "semesters": [1, 2] } | ||
| ] |
This file contains hidden or 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 hidden or 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,9 @@ | ||
| import { mapValues } from 'lodash'; | ||
| import type { ComponentType } from 'react'; | ||
| import * as feather from 'react-feather'; | ||
|
|
||
| module.exports = mapValues(feather, (_component, name) => { | ||
| const MockComponent = jest.fn(() => <div data-testid={`react-feather ${name} icon`} />); | ||
| (MockComponent as ComponentType).displayName = name; | ||
| return MockComponent; | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,32 @@ | ||
| import { render } from '@testing-library/react'; | ||
| import type { ReactNode } from 'react'; | ||
| import { Route, Router } from 'react-router-dom'; | ||
| import createHistory from './createHistory'; | ||
|
|
||
| /** | ||
| * `render` `children` in a `Router` and `Route` so that `children` have | ||
| * populated route matches when using React Router. | ||
| * | ||
| * Inspiration: https://spectrum.chat/testing-library/help-react/attempting-to-test-react-router-match~b0550426-f54a-4b76-b402-c7b32204b55e?m=MTU2OTM1MzY4NjUwNw== | ||
| */ | ||
| export default function renderWithRouterMatch( | ||
| children: ReactNode, | ||
| { | ||
| path = '/', | ||
| location, | ||
| }: { | ||
| path?: string; | ||
| location?: Parameters<typeof createHistory>[0]; | ||
| }, | ||
| ) { | ||
| const { history } = createHistory(location); | ||
| const view = render( | ||
| <Router history={history}> | ||
| <Route path={path}>{children}</Route> | ||
| </Router>, | ||
| ); | ||
| return { | ||
| history, | ||
| view, | ||
| }; | ||
| } |
This file contains hidden or 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 hidden or 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,3 +1,2 @@ | ||
| export const captureException = jest.fn(); | ||
| export const getScriptErrorHandler = jest.fn().mockReturnValue(() => jest.fn()); | ||
| export const retryImport = jest.fn().mockResolvedValue(undefined); |
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| import { retry } from 'utils/promise'; | ||
|
|
||
| /** | ||
| * Wrap an async import() so that it automatically retries in case of a chunk | ||
| * load error and when the user is online | ||
| */ | ||
| export default function retryImport<T>(importFactory: () => Promise<T>, retries = 3) { | ||
| return retry( | ||
| retries, | ||
| importFactory, | ||
| (error) => error.message.includes('Loading chunk ') && window.navigator.onLine, | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| import type { FC } from 'react'; | ||
|
|
||
| const MockRandomKawaii: FC = jest.fn(() => <div data-testid="RandomKawaii component" />); | ||
| export default MockRandomKawaii; |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
createMemoryHistory'sinitialEntriescan only be astring[], so I think this comment is outdated.