-
-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix issue with selecting empty accounts when HW scanning (#4184)
* Fix a bug with selecting empty accounts when HW scanning * Add test
- Loading branch information
1 parent
765a8b9
commit f8f0687
Showing
6 changed files
with
119 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DWAccountDisplay, ExtendedDPath } from '@services/WalletService/deterministic'; | ||
import { TAddress } from '@types'; | ||
|
||
import { fAccount } from './account'; | ||
|
||
const addressToTestWith = fAccount.address as TAddress; | ||
|
||
export const fExtendedDPath: ExtendedDPath = { | ||
name: 'Ledger (ETH)', | ||
path: "m/44'/60'/0'", | ||
offset: 0, | ||
numOfAddresses: 1 | ||
}; | ||
|
||
export const fDWAccountDisplayPreBalance: DWAccountDisplay = { | ||
address: addressToTestWith, | ||
pathItem: { | ||
baseDPath: fExtendedDPath, | ||
path: "m/44'/60'/0'/0", | ||
index: 0 | ||
} | ||
}; | ||
|
||
export const fDWAccountDisplay: DWAccountDisplay = { | ||
...fDWAccountDisplayPreBalance, | ||
balance: '0' | ||
}; |
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,68 @@ | ||
import React from 'react'; | ||
|
||
import { LEDGER_ETH } from '@mycrypto/wallets'; | ||
import { fireEvent, simpleRender, waitFor } from 'test-utils'; | ||
|
||
import { fAssets, fDWAccounts, fNetwork } from '@fixtures'; | ||
import { translateRaw } from '@translations'; | ||
|
||
import HDWList from './HDWList'; | ||
|
||
function getComponent(props: React.ComponentProps<typeof HDWList>) { | ||
return simpleRender(<HDWList {...props} />); | ||
} | ||
|
||
const defaultProps = { | ||
scannedAccounts: fDWAccounts, | ||
asset: fAssets[0], | ||
isCompleted: true, | ||
network: fNetwork, | ||
displayEmptyAddresses: true, | ||
selectedDPath: LEDGER_ETH, | ||
onScanMoreAddresses: jest.fn(), | ||
onUnlock: jest.fn(), | ||
handleUpdate: jest.fn() | ||
}; | ||
|
||
describe('HDWList', () => { | ||
beforeEach(() => { | ||
window.URL.createObjectURL = jest.fn(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('can render', () => { | ||
const props = { ...defaultProps }; | ||
const { getByText } = getComponent(props); | ||
expect( | ||
getByText(translateRaw('DETERMINISTIC_SEE_SUMMARY'), { exact: false }) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('can select/unselect address', async () => { | ||
const props = { ...defaultProps }; | ||
const { getByText, getByTestId } = getComponent(props); | ||
const testId = `row-${fDWAccounts[1].address}`; | ||
const address = getByTestId(testId); | ||
fireEvent.click(address); | ||
await waitFor(() => | ||
expect( | ||
getByText(translateRaw('DETERMINISTIC_SCANNING_EMPTY_ADDR', { $count: '1', $total: '5' }), { | ||
exact: false | ||
}) | ||
).toBeInTheDocument() | ||
); | ||
|
||
const address2 = getByTestId(testId); | ||
fireEvent.click(address2); | ||
await waitFor(() => | ||
expect( | ||
getByText(translateRaw('DETERMINISTIC_SCANNING_EMPTY_ADDR', { $count: '0', $total: '5' }), { | ||
exact: false | ||
}) | ||
).toBeInTheDocument() | ||
); | ||
}); | ||
}); |
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