-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
unit test for filtering accounts #14455
Conversation
48a50d0
to
d578e82
Compare
3d1bf42
to
bfb70e8
Compare
bfb70e8
to
06b8690
Compare
06b8690
to
d6c8eeb
Compare
packages/suite/src/hooks/wallet/coinmarket/form/useCoinmarketVerifyAccount.tsx
Outdated
Show resolved
Hide resolved
packages/suite/src/hooks/wallet/coinmarket/form/useCoinmarketVerifyAccount.tsx
Outdated
Show resolved
Hide resolved
d6c8eeb
to
a073c5d
Compare
@@ -337,4 +340,119 @@ describe('account utils', () => { | |||
account.addresses = enhanceAddresses(accountInfo, account); | |||
expect(account.addresses.change).toEqual([]); | |||
}); | |||
|
|||
it('isDebugOnlyAccountType', () => { |
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.
I think that the test description shall be informative and shall explain what is expected and why:
something like => it('asserts that only ledger and legacy eth accounts are considered as debug, as we don't ..... <real reason why here>' ...
I even think we have something like this in some code style guide.
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.
sorry, re-requested review the same moment you posted this comment. will do
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.
I will leave the description consistent with the file
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.
I don't really agree with the argument of consistency in general, as it can be used to stop any improvement.
However, if you separate this isDebugOnlyAccountType
(and filterReceiveAccounts
) into its own files as Tom asks here the consistency concern won't be the case anyway
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.
Okay yes, I extracted it to another file and will reword the descs
97d61ca
to
311093e
Compare
311093e
to
a5c0f49
Compare
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.
As far as I'm concerned, LGTM 🚀 but please address other reviewers first 🙂
Also it'd be ideal to just slightly expand the tests, see my new comments.
ce1d4e4
to
2cd093e
Compare
@@ -1153,3 +1154,52 @@ export const isTokenMatchesSearch = (token: TokenInfo, search: string) => { | |||
token.policyId?.toLowerCase().includes(search) | |||
); | |||
}; | |||
|
|||
export const isDebugOnlyAccountType = ( |
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.
tbh this file is huge, I would put those new methods into a new file and same with tests. It is going to be better also because the fact that there are helper methods and types for the tests
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.
I extracted it into a new file
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.
Where?
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.
Oh sorry, I only extracted tests, will extract this as well🤦🏻♀️
2cd093e
to
0a991ce
Compare
1bde8ab
to
0891b7a
Compare
}; | ||
|
||
describe('filter receive accounts', () => { | ||
it('check if account is debug only type', () => { |
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.
absolute nitpick:
it('check if account is debug only type', () => { | |
it('checks if account is debug only type', () => { |
expect(isDebugOnlyAccountType('normal', 'regtest')).toBe(false); | ||
}); | ||
|
||
it('empty accounts array', () => { |
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.
it('empty accounts array', () => { | |
it('returns no results, when no accounts are given', () => { |
expect(runFilterReceiveAccouns({ accounts: [] })).toEqual([]); | ||
}); | ||
|
||
it('when given a non-existing network in acccounts list', () => { |
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.
it('when given a non-existing network in acccounts list', () => { | |
it('returns no results for non-existing network in acccounts list', () => { |
expect(runFilterReceiveAccouns({ receiveNetwork: 'bnb' })).toEqual([]); | ||
}); | ||
|
||
it('when debug mode is on', () => { |
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.
it('when debug mode is on', () => { | |
it('filters only debug accounts, when debug mode is on', () => { |
.. and similarly for rest of the it
s
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.
Good job adding new test 👏
0891b7a
to
ed9e076
Compare
ed9e076
to
810bda2
Compare
Thank you, I reworded the its |
Description
Test a complex condition in account filtering
Related Issue
Resolve #13978