-
Notifications
You must be signed in to change notification settings - Fork 298
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
Farzin/76562/Remove legacy connect
method from cashier
#7238
Farzin/76562/Remove legacy connect
method from cashier
#7238
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
Codecov Report
@@ Coverage Diff @@
## develop #7238 +/- ##
===========================================
+ Coverage 19.40% 19.50% +0.09%
===========================================
Files 1478 1477 -1
Lines 34569 34587 +18
Branches 6366 6366
===========================================
+ Hits 6709 6745 +36
+ Misses 27349 27329 -20
- Partials 511 513 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -48,7 +48,6 @@ | |||
"loadjs": "^4.2.0", | |||
"lodash.debounce": "^4.0.8", | |||
"mobx": "^6.6.1", | |||
"mobx-react": "^7.5.1", |
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.
Should’ve been mobx-react-lite
, But seems like we have missed it in merge conflicts and didn’t notice it.
<Routes /> | ||
</StoreProvider> | ||
</MobxContentProvider> | ||
<StoreProvider store={root_store}> |
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.
<StoreProvider store={root_store}> | |
<StoreProvider> |
Later when we could move all stores to the @deriv/stores
we won’t need to pass anything to the provider anymore as the stores already live in the @deriv/stores
package.
// need to wrap withRouter around connect | ||
// to prevent updates on <BinaryRoutes /> from being blocked |
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.
Not sure if this comment is still valid or not, If it is then I guess we need to wrap BinaryRoutes
with observer
but I don’t see any use of stores data in BinaryRoutes
🤔
@@ -1,6 +1,3 @@ | |||
import { useStore } from '@deriv/stores'; | |||
|
|||
export type TRootStore = ReturnType<typeof useStore>; |
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.
We still need to keep TRootStore
in the @deriv/cashier
package as we are overriding the return type of useStore
hook with cashier
stores, Later once we managed to replace cashier
stores with hooks or move them to @deriv/stores
we should be able to remove this as well.
@@ -21,4 +22,8 @@ export default class CounterStore { | |||
decrement() { | |||
this.count = --this.count; | |||
} | |||
|
|||
unmount() { | |||
stopPersisting(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.
We should call stopPersisting
here to solve the warning we get while running tests.
}; | ||
|
||
it('should show proper messages and button', () => { | ||
render(<OnRampProviderCard {...props} />); | ||
const mockRootStore: DeepPartial<TRootStore> = { |
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.
@farzin-deriv could we refactor mockRootStore
to avoid duplication? For example create mockRootStore
in beforeEach
function and in test cases just change the required field. (e.g is_dark_mode_on
in 'should show proper icons in dark_mode' test case)?
@@ -22,32 +17,148 @@ describe('<P2PCashier />', () => { | |||
const history = createBrowserHistory(); | |||
|
|||
it('should render <Loading /> component', () => { | |||
const mockRootStore = { |
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.
@farzin-deriv could we refactor mockRootStore to avoid duplication? For example create mockRootStore in beforeEach function and in test cases just change the required field. (because e.g in 'should render P2P component' test case we only change is_logging_in
field and in 'should redirect to "/cashier/p2p" page with "?order=1" query parameter' test case as i can see there is no any difference with original mockRootStore variable 🤔)?
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.
@george-usynin-binary Yes you are right, We should have a mocked version of the RootStore
so we won’t need to create it each time for each test case, I've already created a card for it and added my proposed API for it, We can discuss it and come up with better ideas 🙇🏻
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Changes:
Please include a summary of the change and which issue is fixed below:
When you need to add unit test
When you need to add integration test
Test coverage checklist (for reviewer)
Type of change