From 5ace69a383630da2fd65382d9cae640e20196426 Mon Sep 17 00:00:00 2001 From: Justin Tormey Date: Wed, 29 Nov 2017 14:22:29 -0500 Subject: [PATCH] feat(BCH): add bch to currency balance stats --- src/api.js | 6 +++--- tests/api.spec.js | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/api.js b/src/api.js index 3e19bac6c..03abb21f9 100644 --- a/src/api.js +++ b/src/api.js @@ -308,10 +308,10 @@ API.prototype.incrementLoginViaQrStats = function () { return fetch(this.ROOT_URL + 'event?name=wallet_web_login_via_qr'); }; -API.prototype.incrementBtcEthUsageStats = function (btcBalance, ethBalance) { +API.prototype.incrementCurrencyUsageStats = function (btcBalance, ethBalance, bchBalance) { let base = this.ROOT_URL + 'event?name=wallet_login_balance'; - let makeEventUrl = (btc, eth) => `${base}_btc_${btc ? 1 : 0}_eth_${eth ? 1 : 0}`; - fetch(makeEventUrl(btcBalance > 0, ethBalance > 0)); + let makeEventUrl = (btc, eth, bch) => `${base}_btc_${btc ? 1 : 0}_eth_${eth ? 1 : 0}_bch_${bch ? 1 : 0}`; + fetch(makeEventUrl(btcBalance > 0, ethBalance > 0, bchBalance > 0)); }; API.prototype.getPriceChartData = function (params) { diff --git a/tests/api.spec.js b/tests/api.spec.js index 1ee4d0807..dfac83cbb 100644 --- a/tests/api.spec.js +++ b/tests/api.spec.js @@ -19,7 +19,7 @@ describe('API', () => { }); }); - describe('.incrementBtcEthUsageStats', () => { + describe('.incrementCurrencyUsageStats', () => { let eventUrl = (event) => `https://blockchain.info/event?name=wallet_login_balance_${event}` beforeEach(() => { @@ -27,28 +27,33 @@ describe('API', () => { }) it('should make one request', () => { - API.incrementBtcEthUsageStats(0, 0) + API.incrementCurrencyUsageStats(0, 0) expect(window.fetch).toHaveBeenCalledTimes(1) }) it('should record correctly for btc=0, eth=0', () => { - API.incrementBtcEthUsageStats(0, 0) - expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_0')) + API.incrementCurrencyUsageStats(0, 0) + expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_0_bch_0')) }) it('should record correctly for btc>0, eth=0', () => { - API.incrementBtcEthUsageStats(1, 0) - expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_0')) + API.incrementCurrencyUsageStats(1, 0) + expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_0_bch_0')) }) it('should record correctly for btc=0, eth>0', () => { - API.incrementBtcEthUsageStats(0, 1) - expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_1')) + API.incrementCurrencyUsageStats(0, 1) + expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_1_bch_0')) }) it('should record correctly for btc>0, eth>0', () => { - API.incrementBtcEthUsageStats(1, 1) - expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_1')) + API.incrementCurrencyUsageStats(1, 1) + expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_1_bch_0')) + }) + + it('should record correctly for bch>0', () => { + API.incrementCurrencyUsageStats(0, 0, 1) + expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_0_bch_1')) }) }) });