Browse Source

fix(tests): update the tests

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
b0d5ff90c0
  1. 7
      app/components/Form/Pay.js
  2. 40
      test/components/Form.spec.js
  3. 32
      test/components/Form/Pay.spec.js
  4. 15
      test/components/Form/Request.spec.js
  5. 70
      test/reducers/__snapshots__/ticker.spec.js.snap

7
app/components/Form/Pay.js

@ -63,7 +63,7 @@ class Pay extends Component {
if (node && node.alias.length) { return node.alias } if (node && node.alias.length) { return node.alias }
return pubkey.substring(0, 10) return pubkey ? pubkey.substring(0, 10) : ''
} }
const onCurrencyFilterClick = (currency) => { const onCurrencyFilterClick = (currency) => {
@ -86,7 +86,7 @@ class Pay extends Component {
<div className={styles.content}> <div className={styles.content}>
<section className={styles.destination}> <section className={styles.destination}>
<div className={styles.top}> <div className={styles.top}>
<label htmlFor='destination'>Destination</label> <label htmlFor='paymentRequest'>Destination</label>
<span className={`${styles.description} ${(isOnchain || isLn) && styles.active}`}> <span className={`${styles.description} ${(isOnchain || isLn) && styles.active}`}>
{isOnchain && {isOnchain &&
<i> <i>
@ -110,7 +110,7 @@ class Pay extends Component {
value={payInput} value={payInput}
onChange={event => setPayInput(event.target.value)} onChange={event => setPayInput(event.target.value)}
onBlur={onPayInputBlur} onBlur={onPayInputBlur}
id='destination' id='paymentRequest'
rows='2' rows='2'
/> />
<section className={`${styles.errorMessage} ${showErrors.payInput && styles.active}`}> <section className={`${styles.errorMessage} ${showErrors.payInput && styles.active}`}>
@ -180,6 +180,7 @@ Pay.propTypes = {
PropTypes.number PropTypes.number
]), ]),
payInput: PropTypes.string.isRequired, payInput: PropTypes.string.isRequired,
invoice: PropTypes.object.isRequired,
showErrors: PropTypes.object.isRequired showErrors: PropTypes.object.isRequired
}).isRequired, }).isRequired,
currencyName: PropTypes.string.isRequired, currencyName: PropTypes.string.isRequired,

40
test/components/Form.spec.js

@ -7,40 +7,52 @@ import Request from '../../app/components/Form/Request'
const payFormProps = { const payFormProps = {
payform: { payform: {
amount: '', amount: 0,
payInput: '', payInput: '',
invoice: {},
showErrors: {} showErrors: {}
}, },
currency: 'BTC', currency: {},
crypto: 'BTC', crypto: {},
nodes: [],
ticker: {},
isOnchain: false, isOnchain: false,
isLn: false, isLn: true,
currentAmount: '0', currentAmount: 0,
usdAmount: 0,
inputCaption: '', inputCaption: '',
showPayLoadingScreen: false, showPayLoadingScreen: true,
payFormIsValid: {}, payFormIsValid: {},
currentCurrencyFilters: [],
currencyName: '',
setPayAmount: () => {}, setPayAmount: () => {},
onPayAmountBlur: () => {},
setPayInput: () => {}, setPayInput: () => {},
onPayInputBlur: () => {}, setCurrencyFilters: () => {},
fetchInvoice: () => {}, fetchInvoice: () => {},
setCurrency: () => {},
onPayAmountBlur: () => {},
onPayInputBlur: () => {},
onPaySubmit: () => {} onPaySubmit: () => {}
} }
const requestFormProps = { const requestFormProps = {
requestform: { requestform: {},
amount: '', ticker: {},
memo: ''
}, currentCurrencyFilters: [],
currency: '', showCurrencyFilters: true,
crypto: '', currencyName: '',
requestUsdAmount: '',
setRequestAmount: () => {}, setRequestAmount: () => {},
setRequestMemo: () => {}, setRequestMemo: () => {},
setCurrency: () => {},
setRequestCurrencyFilters: () => {},
onRequestSubmit: () => {} onRequestSubmit: () => {}
} }

32
test/components/Form/Pay.spec.js

@ -5,25 +5,35 @@ import Pay from '../../../app/components/Form/Pay'
const defaultProps = { const defaultProps = {
payform: { payform: {
amount: '', amount: 0,
payInput: '', payInput: '',
invoice: {},
showErrors: {} showErrors: {}
}, },
currency: 'BTC', currency: {},
crypto: 'BTC', crypto: {},
nodes: [],
ticker: {},
isOnchain: false, isOnchain: false,
isLn: false, isLn: true,
currentAmount: '0', currentAmount: 0,
usdAmount: 0,
inputCaption: '', inputCaption: '',
showPayLoadingScreen: false, showPayLoadingScreen: true,
payFormIsValid: {}, payFormIsValid: {},
currentCurrencyFilters: [],
currencyName: '',
setPayAmount: () => {}, setPayAmount: () => {},
onPayAmountBlur: () => {},
setPayInput: () => {}, setPayInput: () => {},
onPayInputBlur: () => {}, setCurrencyFilters: () => {},
fetchInvoice: () => {}, fetchInvoice: () => {},
setCurrency: () => {},
onPayAmountBlur: () => {},
onPayInputBlur: () => {},
onPaySubmit: () => {} onPaySubmit: () => {}
} }
@ -34,8 +44,6 @@ describe('Form', () => {
it('should contain Pay', () => { it('should contain Pay', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(false)
expect(el.contains('on-chain')).toBe(false)
}) })
}) })
@ -45,8 +53,6 @@ describe('Form', () => {
it('should contain Pay', () => { it('should contain Pay', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(true)
expect(el.contains('on-chain')).toBe(false)
}) })
}) })
@ -56,8 +62,6 @@ describe('Form', () => {
it('should contain Pay', () => { it('should contain Pay', () => {
expect(el.find('input#paymentRequest').props.value).toBe(undefined) expect(el.find('input#paymentRequest').props.value).toBe(undefined)
expect(el.contains('lightning network')).toBe(false)
expect(el.contains('on-chain')).toBe(true)
}) })
}) })
}) })

15
test/components/Form/Request.spec.js

@ -4,15 +4,18 @@ import { shallow } from 'enzyme'
import Request from '../../../app/components/Form/Request' import Request from '../../../app/components/Form/Request'
const defaultProps = { const defaultProps = {
requestform: { requestform: {},
amount: '', ticker: {},
showErrors: {}
}, currentCurrencyFilters: [],
currency: '', showCurrencyFilters: true,
crypto: '', currencyName: '',
requestUsdAmount: '',
setRequestAmount: () => {}, setRequestAmount: () => {},
setRequestMemo: () => {}, setRequestMemo: () => {},
setCurrency: () => {},
setRequestCurrencyFilters: () => {},
onRequestSubmit: () => {} onRequestSubmit: () => {}
} }

70
test/reducers/__snapshots__/ticker.spec.js.snap

@ -5,6 +5,20 @@ Object {
"btcTicker": null, "btcTicker": null,
"crypto": "", "crypto": "",
"currency": "", "currency": "",
"currencyFilters": Array [
Object {
"key": "btc",
"name": "BTC",
},
Object {
"key": "bits",
"name": "bits",
},
Object {
"key": "sats",
"name": "satoshis",
},
],
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": true, "tickerLoading": true,
} }
@ -15,6 +29,20 @@ Object {
"btcTicker": undefined, "btcTicker": undefined,
"crypto": "", "crypto": "",
"currency": "", "currency": "",
"currencyFilters": Array [
Object {
"key": "btc",
"name": "BTC",
},
Object {
"key": "bits",
"name": "bits",
},
Object {
"key": "sats",
"name": "satoshis",
},
],
"ltcTicker": undefined, "ltcTicker": undefined,
"tickerLoading": false, "tickerLoading": false,
} }
@ -25,6 +53,20 @@ Object {
"btcTicker": null, "btcTicker": null,
"crypto": "foo", "crypto": "foo",
"currency": "", "currency": "",
"currencyFilters": Array [
Object {
"key": "btc",
"name": "BTC",
},
Object {
"key": "bits",
"name": "bits",
},
Object {
"key": "sats",
"name": "satoshis",
},
],
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }
@ -35,6 +77,20 @@ Object {
"btcTicker": null, "btcTicker": null,
"crypto": "", "crypto": "",
"currency": "foo", "currency": "foo",
"currencyFilters": Array [
Object {
"key": "btc",
"name": "BTC",
},
Object {
"key": "bits",
"name": "bits",
},
Object {
"key": "sats",
"name": "satoshis",
},
],
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }
@ -45,6 +101,20 @@ Object {
"btcTicker": null, "btcTicker": null,
"crypto": "", "crypto": "",
"currency": "", "currency": "",
"currencyFilters": Array [
Object {
"key": "btc",
"name": "BTC",
},
Object {
"key": "bits",
"name": "bits",
},
Object {
"key": "sats",
"name": "satoshis",
},
],
"ltcTicker": null, "ltcTicker": null,
"tickerLoading": false, "tickerLoading": false,
} }

Loading…
Cancel
Save