Browse Source

refactor: remove unused components

renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
13456488ed
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 23
      app/components/CryptoIcon/CryptoIcon.js
  2. 3
      app/components/CryptoIcon/index.js
  3. 20
      app/components/CurrencyIcon/CurrencyIcon.js
  4. 3
      app/components/CurrencyIcon/index.js
  5. 39
      test/unit/components/CryptoIcon.spec.js
  6. 32
      test/unit/components/CurrencyIcon.spec.js

23
app/components/CryptoIcon/CryptoIcon.js

@ -1,23 +0,0 @@
import React from 'react'
import PropTypes from 'prop-types'
import SkinnyBitcoin from 'components/Icon/SkinnyBitcoin'
import Litecoin from 'components/Icon/Litecoin'
const CryptoIcon = ({ currency, styles }) => {
switch (currency) {
case 'btc':
return <SkinnyBitcoin style={styles} />
case 'ltc':
return <Litecoin style={styles} />
default:
return <span />
}
}
CryptoIcon.propTypes = {
currency: PropTypes.string.isRequired,
styles: PropTypes.object
}
export default CryptoIcon

3
app/components/CryptoIcon/index.js

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

20
app/components/CurrencyIcon/CurrencyIcon.js

@ -1,20 +0,0 @@
import React from 'react'
import PropTypes from 'prop-types'
import FaDollar from 'react-icons/lib/fa/dollar'
import CryptoIcon from '../CryptoIcon'
const CurrencyIcon = ({ currency, crypto, styles }) => {
return currency === 'usd' ? (
<FaDollar style={styles} />
) : (
<CryptoIcon styles={styles} currency={crypto} />
)
}
CurrencyIcon.propTypes = {
currency: PropTypes.string.isRequired,
crypto: PropTypes.string.isRequired,
styles: PropTypes.object
}
export default CurrencyIcon

3
app/components/CurrencyIcon/index.js

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

39
test/unit/components/CryptoIcon.spec.js

@ -1,39 +0,0 @@
import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import CryptoIcon from 'components/CryptoIcon'
import SkinnyBitcoin from 'components/Icon/SkinnyBitcoin'
import Litecoin from 'components/Icon/Litecoin'
configure({ adapter: new Adapter() })
const defaultProps = {
currency: 'bch',
styles: {}
}
describe('component.CryptoIcon', () => {
describe('currency is "unknown"', () => {
const props = { ...defaultProps }
const el = shallow(<CryptoIcon {...props} />)
it('should show empty span', () => {
expect(el.html()).toEqual('<span></span>')
})
})
describe('currency is "btc"', () => {
const props = { ...defaultProps, currency: 'btc' }
const el = shallow(<CryptoIcon {...props} />)
it('should show btc symbol', () => {
expect(el.find(SkinnyBitcoin)).toHaveLength(1)
})
})
describe('currency is "ltc"', () => {
const props = { ...defaultProps, currency: 'ltc' }
const el = shallow(<CryptoIcon {...props} />)
it('should show ltc symbol', () => {
expect(el.find(Litecoin)).toHaveLength(1)
})
})
})

32
test/unit/components/CurrencyIcon.spec.js

@ -1,32 +0,0 @@
import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import FaDollar from 'react-icons/lib/fa/dollar'
import CryptoIcon from 'components/CryptoIcon'
import CurrencyIcon from 'components/CurrencyIcon'
configure({ adapter: new Adapter() })
const defaultProps = {
currency: '',
crypto: '',
styles: {}
}
describe('component.CurrencyIcon', () => {
describe('currency is "usd"', () => {
const props = { ...defaultProps, currency: 'usd' }
const el = shallow(<CurrencyIcon {...props} />)
it('should show usd symbol', () => {
expect(el.find(FaDollar)).toHaveLength(1)
})
})
describe('currency is not "usd"', () => {
const props = { ...defaultProps, currency: 'btc' }
const el = shallow(<CurrencyIcon {...props} />)
it('should show btc symbol', () => {
expect(el.find(CryptoIcon)).toHaveLength(1)
})
})
})
Loading…
Cancel
Save