From 977937956eb96fd12802c12922de7e2eab21aac7 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Wed, 19 Sep 2018 18:32:19 +0200 Subject: [PATCH] chore(fs): remove unused util code Our USD helper functions are no longer used since we have migrated to intl for currency formatting. Remove the unused code. --- app/lib/utils/index.js | 1 - app/lib/utils/usd.js | 16 ---------------- test/unit/utils/usd.spec.js | 27 --------------------------- 3 files changed, 44 deletions(-) delete mode 100644 app/lib/utils/usd.js delete mode 100644 test/unit/utils/usd.spec.js diff --git a/app/lib/utils/index.js b/app/lib/utils/index.js index cdf18be9..b487fedb 100644 --- a/app/lib/utils/index.js +++ b/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' diff --git a/app/lib/utils/usd.js b/app/lib/utils/usd.js deleted file mode 100644 index 47cc2f77..00000000 --- a/app/lib/utils/usd.js +++ /dev/null @@ -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 -} diff --git a/test/unit/utils/usd.spec.js b/test/unit/utils/usd.spec.js deleted file mode 100644 index 18044f45..00000000 --- a/test/unit/utils/usd.spec.js +++ /dev/null @@ -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') - }) - }) -})