Browse Source

Merge pull request #793 from mrfelton/chore/remove-unused-code

chore(fs): remove unused util code
renovate/lint-staged-8.x
JimmyMow 6 years ago
committed by GitHub
parent
commit
bf433a5450
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/lib/utils/index.js
  2. 16
      app/lib/utils/usd.js
  3. 27
      test/unit/utils/usd.spec.js

1
app/lib/utils/index.js

@ -1,4 +1,3 @@
export btc from './btc'
export usd from './usd'
export bech32 from './bech32'
export blockExplorer from './blockExplorer'

16
app/lib/utils/usd.js

@ -1,16 +0,0 @@
export function formatUsd(usd) {
return `$${(+usd).toFixed(2)}`
}
export function usdToBtc(usd, rate) {
if (usd === undefined || usd === null || usd === '') {
return null
}
return (usd / rate).toFixed(8)
}
export default {
formatUsd,
usdToBtc
}

27
test/unit/utils/usd.spec.js

@ -1,27 +0,0 @@
import { formatUsd, usdToBtc } from 'lib/utils/usd'
describe('usd', () => {
describe('formatUsd', () => {
it('should handle a string value', () => {
expect(formatUsd('42.0')).toBe('$42.00')
})
it('should handle a numerical value', () => {
expect(formatUsd(42.0)).toBe('$42.00')
})
it('should round to two decimal places', () => {
expect(formatUsd('42.416')).toBe('$42.42')
})
})
describe('usdToBtc', () => {
it('should convert USD to BTC using rate', () => {
expect(usdToBtc(1, 50)).toBe('0.02000000')
})
it('should round to eight decimal places', () => {
expect(usdToBtc(2, 3)).toBe('0.66666667')
})
})
})
Loading…
Cancel
Save