From 6b38fd626d404269b8791da2691ebf8c2243a72f Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Tue, 13 Mar 2018 16:07:09 +0100 Subject: [PATCH] Update tests --- src/components/dashboard/index.test.js | 2 +- src/components/resultBox/resultBox.test.js | 1 + src/components/send/index.js | 17 +++++------------ src/components/send/index.test.js | 2 +- test/integration/wallet.test.js | 2 +- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/components/dashboard/index.test.js b/src/components/dashboard/index.test.js index 8f41571db2..8a3eff9ebf 100644 --- a/src/components/dashboard/index.test.js +++ b/src/components/dashboard/index.test.js @@ -33,7 +33,7 @@ describe('Dashboard', () => { account: { address: 'some address' }, }, }; - wrapper = mountWithContext(, context); + wrapper = mountWithContext(, context); }); it('should render transaction list with at most 3 transactions', () => { diff --git a/src/components/resultBox/resultBox.test.js b/src/components/resultBox/resultBox.test.js index 44b230024d..a2a42145b5 100644 --- a/src/components/resultBox/resultBox.test.js +++ b/src/components/resultBox/resultBox.test.js @@ -35,6 +35,7 @@ describe('Result Box', () => { copyToClipboard: () => {}, finalCallback: () => {}, t: () => {}, + history: { location: {}, push: () => {} }, }; wrapper = mount(, options); diff --git a/src/components/send/index.js b/src/components/send/index.js index e35a587644..890a880b5d 100644 --- a/src/components/send/index.js +++ b/src/components/send/index.js @@ -15,20 +15,13 @@ import styles from './send.css'; class Send extends React.Component { constructor(props) { super(props); - const { address, amount } = parseSearchParams(props.history.location.search); this.state = { - address, - amount, - sendIsActive: !!address, + sendIsActive: !!this.getSearchParams().address || !!this.getSearchParams().amount, }; } - componentWillReceiveProps(nextProps) { - const { address, amount } = parseSearchParams(nextProps.history.location); - - if (address !== this.state.address || amount !== this.state.amount) { - this.setState({ address, amount }); - } + getSearchParams() { + return parseSearchParams(this.props.history.location.search); } setSendIsActive(sendIsActive) { @@ -54,8 +47,8 @@ class Send extends React.Component { className={styles.wrapper}> breakpoints.m} - address={this.state.address} - amount={this.state.amount} + address={this.getSearchParams().address} + amount={this.getSearchParams().amount} /> diff --git a/src/components/send/index.test.js b/src/components/send/index.test.js index 217230a59f..b66fd873a9 100644 --- a/src/components/send/index.test.js +++ b/src/components/send/index.test.js @@ -27,7 +27,7 @@ describe('Send', () => { context = { storeState, }; - wrapper = mountWithContext(, context); + wrapper = mountWithContext(, context); }); it('should render MultiStep component ', () => { diff --git a/test/integration/wallet.test.js b/test/integration/wallet.test.js index d1a69867f2..9a265654cf 100644 --- a/test/integration/wallet.test.js +++ b/test/integration/wallet.test.js @@ -117,7 +117,7 @@ describe('@integration: Wallet', () => { store.dispatch(activePeerSet({ network: getNetwork(networks.mainnet.code) })); accountAPIStub.withArgs(match.any).returnsPromise().resolves({ ...account }); store.dispatch(accountLoggedIn(account)); - wrapper = mount(renderWithRouter(Wallet, store, { location: { search: '' } })); + wrapper = mount(renderWithRouter(Wallet, store, { history: { location: { search: '' } } })); helper = new Helper(wrapper, store); };