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. 15
      app/components/Nav/Nav.js
  3. 3
      app/components/Wallet/Wallet.js
  4. 8
      app/lnd/methods/index.js
  5. 1
      app/reducers/channels.js
  6. 2
      app/reducers/invoice.js
  7. 2
      app/reducers/peers.js
  8. 4
      app/routes/app/components/App.js
  9. 1
      app/routes/app/containers/AppContainer.js
  10. 1
      test/components/Channels.spec.js
  11. 20
      test/components/Nav.spec.js
  12. 3
      test/components/Peers.spec.js

1
app/components/GlobalError/GlobalError.js

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

15
app/components/Nav/Nav.js

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

3
app/components/Wallet/Wallet.js

@ -3,7 +3,6 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { FaQrcode } from 'react-icons/lib/fa' import { FaQrcode } from 'react-icons/lib/fa'
import Isvg from 'react-inlinesvg' import Isvg from 'react-inlinesvg'
import CryptoIcon from 'components/CryptoIcon'
import { btc } from 'utils' import { btc } from 'utils'
import ReceiveModal from './ReceiveModal' import ReceiveModal from './ReceiveModal'
import styles from './Wallet.scss' import styles from './Wallet.scss'
@ -19,7 +18,6 @@ class Wallet extends Component {
render() { render() {
const { const {
ticker,
balance, balance,
address, address,
info info
@ -64,7 +62,6 @@ class Wallet extends Component {
} }
Wallet.propTypes = { Wallet.propTypes = {
ticker: PropTypes.object.isRequired,
balance: PropTypes.object.isRequired, balance: PropTypes.object.isRequired,
address: PropTypes.string.isRequired, address: PropTypes.string.isRequired,
info: PropTypes.object.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) console.log('addInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() }) event.sender.send('invoiceFailed', { error: error.toString() })
}) })
@ -115,7 +115,7 @@ export default function (lnd, event, msg, data) {
// { paymentRequest } = data // { paymentRequest } = data
paymentsController.sendPaymentSync(lnd, data) paymentsController.sendPaymentSync(lnd, data)
.then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route }))) .then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route })))
.catch(error => { .catch((error) => {
console.log('payinvoice error: ', error) console.log('payinvoice error: ', error)
event.sender.send('paymentFailed', { error: error.toString() }) event.sender.send('paymentFailed', { error: error.toString() })
}) })
@ -125,7 +125,7 @@ export default function (lnd, event, msg, data) {
// { amount, addr } = data // { amount, addr } = data
walletController.sendCoins(lnd, data) walletController.sendCoins(lnd, data)
.then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid })) .then(({ txid }) => event.sender.send('transactionSuccessful', { amount: data.amount, addr: data.addr, txid }))
.catch(error => { .catch((error) => {
console.log('error: ', error) console.log('error: ', error)
event.sender.send('transactionError', { error: error.toString() }) event.sender.send('transactionError', { error: error.toString() })
}) })
@ -158,7 +158,7 @@ export default function (lnd, event, msg, data) {
console.log('peer_id: ', peer_id) console.log('peer_id: ', peer_id)
event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, 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() }) event.sender.send('connectFailure', { error: error.toString() })
console.log('connectPeer error: ', error) console.log('connectPeer error: ', error)
}) })

1
app/reducers/channels.js

@ -90,7 +90,6 @@ export const channelSuccessful = () => (dispatch) => {
// Receive IPC event for updated channel // Receive IPC event for updated channel
export const pushchannelupdated = () => (dispatch) => { export const pushchannelupdated = () => (dispatch) => {
console.log('channelUpdatedData: ', channelUpdatedData)
dispatch(fetchChannels()) dispatch(fetchChannels())
} }

2
app/reducers/invoice.js

@ -112,7 +112,7 @@ export const createdInvoice = (event, invoice) => (dispatch) => {
dispatch(resetRequestForm()) dispatch(resetRequestForm())
} }
export const invoiceFailed = (event, { error }) => dispatch => { export const invoiceFailed = (event, { error }) => (dispatch) => {
dispatch({ type: INVOICE_FAILED }) dispatch({ type: INVOICE_FAILED })
dispatch(setError(error)) 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 }) export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer })
// Send IPC receive for unsuccessfully connecting to a 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({ type: CONNECT_FAILURE })
dispatch(setError(error)) dispatch(setError(error))
} }

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

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

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

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

1
test/components/Channels.spec.js

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

20
test/components/Nav.spec.js

@ -22,27 +22,11 @@ describe('default elements', () => {
const props = { ...defaultProps } const props = { ...defaultProps }
const el = shallow(<Nav {...props} />) 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', () => { it('should render nav links', () => {
expect(el.find(NavLink).at(0).props().to).toBe('/') expect(el.find(NavLink).at(0).props().to).toBe('/')
expect(el.find(NavLink).at(1).props().to).toBe('/wallet') expect(el.find(NavLink).at(1).props().to).toBe('/wallet')
expect(el.find(FaClockO)).toHaveLength(1) expect(el.find(NavLink).at(2).props().to).toBe('/channels')
expect(el.find(MdAccountBalanceWallet)).toHaveLength(1) expect(el.find(NavLink).at(3).props().to).toBe('/settings')
}) })
it('should render buttons', () => { it('should render buttons', () => {
expect(el.find('.button').at(0).text()).toContain('Pay') expect(el.find('.button').at(0).text()).toContain('Pay')

3
test/components/Peers.spec.js

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

Loading…
Cancel
Save