Browse Source

fix(lint, tests): fix linting errors and tests

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
9ad4beb03f
  1. 1
      app/components/GlobalError/GlobalError.js
  2. 2
      app/components/GlobalError/index.js
  3. 15
      app/components/Nav/Nav.js
  4. 3
      app/components/Wallet/Wallet.js
  5. 8
      app/lnd/methods/index.js
  6. 3
      app/reducers/channels.js
  7. 2
      app/reducers/invoice.js
  8. 2
      app/reducers/peers.js
  9. 4
      app/routes/app/components/App.js
  10. 1
      app/routes/app/containers/AppContainer.js
  11. 1
      test/components/Channels.spec.js
  12. 20
      test/components/Nav.spec.js
  13. 3
      test/components/Peers.spec.js

1
app/components/GlobalError/GlobalError.js

@ -15,7 +15,6 @@ const GlobalError = ({ error, clearError }) => (
)
GlobalError.propTypes = {
error: PropTypes.string,
clearError: PropTypes.func.isRequired

2
app/components/GlobalError/index.js

@ -1,3 +1,3 @@
import GlobalError from './GlobalError'
export default GlobalError
export default GlobalError

15
app/components/Nav/Nav.js

@ -2,10 +2,7 @@ import path from 'path'
import React from 'react'
import PropTypes from 'prop-types'
import { NavLink } from 'react-router-dom'
import ReactSVG from 'react-svg'
import Isvg from 'react-inlinesvg'
import { MdAccountBalanceWallet } from 'react-icons/lib/md'
import { FaClockO, FaBolt } from 'react-icons/lib/fa'
import styles from './Nav.scss'
const Nav = ({ openPayForm, openRequestForm }) => (
@ -16,32 +13,28 @@ const Nav = ({ openPayForm, openRequestForm }) => (
</header>
<ul className={styles.links}>
<NavLink exact to='/' activeClassName={styles.active} className={styles.link}>
<span className={styles.activeBorder}>
</span>
<span className={styles.activeBorder} />
<li>
<Isvg styles={{ verticalAlign: 'middle' }} src={path.join(__dirname, '..', 'resources/icons/wallet.svg')} />
<span>Wallet</span>
</li>
</NavLink>
<NavLink exact to='/wallet' activeClassName={styles.active} className={styles.link}>
<span className={styles.activeBorder}>
</span>
<span className={styles.activeBorder} />
<li>
<Isvg styles={{ verticalAlign: 'middle' }} src={path.join(__dirname, '..', 'resources/icons/peers.svg')} />
<span>Peers</span>
</li>
</NavLink>
<NavLink exact to='/channels' activeClassName={styles.active} className={styles.link}>
<span className={styles.activeBorder}>
</span>
<span className={styles.activeBorder} />
<li>
<Isvg styles={{ verticalAlign: 'middle' }} src={path.join(__dirname, '..', 'resources/icons/channels.svg')} />
<span>Channels</span>
</li>
</NavLink>
<NavLink exact to='/settings' activeClassName={styles.active} className={styles.link}>
<span className={styles.activeBorder}>
</span>
<span className={styles.activeBorder} />
<li>
<Isvg styles={{ verticalAlign: 'middle' }} src={path.join(__dirname, '..', 'resources/icons/settings.svg')} />
<span>Settings</span>

3
app/components/Wallet/Wallet.js

@ -3,7 +3,6 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { FaQrcode } from 'react-icons/lib/fa'
import Isvg from 'react-inlinesvg'
import CryptoIcon from 'components/CryptoIcon'
import { btc } from 'utils'
import ReceiveModal from './ReceiveModal'
import styles from './Wallet.scss'
@ -19,7 +18,6 @@ class Wallet extends Component {
render() {
const {
ticker,
balance,
address,
info
@ -64,7 +62,6 @@ class Wallet extends Component {
}
Wallet.propTypes = {
ticker: PropTypes.object.isRequired,
balance: PropTypes.object.isRequired,
address: PropTypes.string.isRequired,
info: PropTypes.object.isRequired

8
app/lnd/methods/index.js

@ -105,7 +105,7 @@ export default function (lnd, event, msg, data) {
})
)
)
.catch(error => {
.catch((error) => {
console.log('addInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() })
})
@ -115,7 +115,7 @@ export default function (lnd, event, msg, data) {
// { paymentRequest } = data
paymentsController.sendPaymentSync(lnd, data)
.then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route })))
.catch(error => {
.catch((error) => {
console.log('payinvoice error: ', error)
event.sender.send('paymentFailed', { error: error.toString() })
})
@ -125,7 +125,7 @@ export default function (lnd, event, msg, data) {
// { amount, addr } = data
walletController.sendCoins(lnd, data)
.then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid }))
.catch(error => {
.catch((error) => {
console.log('error: ', error)
event.sender.send('transactionError', { error: error.toString() })
})
@ -158,7 +158,7 @@ export default function (lnd, event, msg, data) {
console.log('peer_id: ', peer_id)
event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id })
})
.catch(error => {
.catch((error) => {
event.sender.send('connectFailure', { error: error.toString() })
console.log('connectPeer error: ', error)
})

3
app/reducers/channels.js

@ -90,7 +90,6 @@ export const channelSuccessful = () => (dispatch) => {
// Receive IPC event for updated channel
export const pushchannelupdated = () => (dispatch) => {
console.log('channelUpdatedData: ', channelUpdatedData)
dispatch(fetchChannels())
}
@ -174,7 +173,7 @@ const ACTION_HANDLERS = {
[OPENING_CHANNEL]: state => ({ ...state, openingChannel: true }),
[OPENING_FAILURE]: state => ({ ...state, openingChannel: false }),
[CLOSING_CHANNEL]: state => ({ ...state, closingChannel: true })
}

2
app/reducers/invoice.js

@ -112,7 +112,7 @@ export const createdInvoice = (event, invoice) => (dispatch) => {
dispatch(resetRequestForm())
}
export const invoiceFailed = (event, { error }) => dispatch => {
export const invoiceFailed = (event, { error }) => (dispatch) => {
dispatch({ type: INVOICE_FAILED })
dispatch(setError(error))
}

2
app/reducers/peers.js

@ -79,7 +79,7 @@ export const connectRequest = ({ pubkey, host }) => (dispatch) => {
export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer })
// Send IPC receive for unsuccessfully connecting to a peer
export const connectFailure = (event, { error }) => dispatch => {
export const connectFailure = (event, { error }) => (dispatch) => {
dispatch({ type: CONNECT_FAILURE })
dispatch(setError(error))
}

4
app/routes/app/components/App.js

@ -79,7 +79,6 @@ class App extends Component {
<div className={styles.content}>
<Wallet
ticker={ticker}
balance={balance}
address={address}
info={info}
@ -105,6 +104,7 @@ App.propTypes = {
form: PropTypes.object.isRequired,
formProps: PropTypes.object.isRequired,
closeForm: PropTypes.func.isRequired,
error: PropTypes.object.isRequired,
newAddress: PropTypes.func.isRequired,
fetchInfo: PropTypes.func.isRequired,
@ -113,9 +113,11 @@ App.propTypes = {
fetchBalance: PropTypes.func.isRequired,
openPayForm: PropTypes.func.isRequired,
openRequestForm: PropTypes.func.isRequired,
clearError: PropTypes.func.isRequired,
currentTicker: PropTypes.object,
children: PropTypes.object.isRequired
}

1
app/routes/app/containers/AppContainer.js

@ -50,7 +50,6 @@ const mapDispatchToProps = {
fetchInvoice,
fetchBlockHeight,
clearError,
clearError
}

1
test/components/Channels.spec.js

@ -21,6 +21,7 @@ const defaultProps = {
allChannels: [],
openChannel: () => {},
closeChannel: () => {},
fetchChannels: () => {},
currentTicker: {},
explorerLinkBase: 'https://testnet.smartbit.com.au'
}

20
test/components/Nav.spec.js

@ -22,27 +22,11 @@ describe('default elements', () => {
const props = { ...defaultProps }
const el = shallow(<Nav {...props} />)
describe('currencies', () => {
it('should render currency conversion links', () => {
expect(el.find('.currencies').length).toBe(1)
expect(el.find(FaDollar).length).toBe(1)
})
})
describe('balances', () => {
expect(el.find('.balance').length).toBe(1)
it('should render wallet balance', () => {})
it('should render channel balance', () => {})
})
it('should render logo', () => {
expect(el.find(ReactSVG).props().path).toContain('zap_2.svg')
})
it('should render nav links', () => {
expect(el.find(NavLink).at(0).props().to).toBe('/')
expect(el.find(NavLink).at(1).props().to).toBe('/wallet')
expect(el.find(FaClockO)).toHaveLength(1)
expect(el.find(MdAccountBalanceWallet)).toHaveLength(1)
expect(el.find(NavLink).at(2).props().to).toBe('/channels')
expect(el.find(NavLink).at(3).props().to).toBe('/settings')
})
it('should render buttons', () => {
expect(el.find('.button').at(0).text()).toContain('Pay')

3
test/components/Peers.spec.js

@ -19,7 +19,8 @@ const defaultProps = {
resetPeer: () => {},
disconnect: () => {},
form: {},
setForm: () => {}
setForm: () => {},
fetchPeers: () => {}
}
const peer = {

Loading…
Cancel
Save