Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
feat(BCH): add bch to currency balance stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore3 committed Nov 29, 2017
1 parent cfdec32 commit 5ace69a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ API.prototype.incrementLoginViaQrStats = function () {
return fetch(this.ROOT_URL + 'event?name=wallet_web_login_via_qr');

This comment has been minimized.

Copy link
@1Bennell

1Bennell Jul 29, 2018

Fetch

This comment has been minimized.

Copy link
@1Bennell

1Bennell Jul 29, 2018

bch

};

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) {
Expand Down
25 changes: 15 additions & 10 deletions tests/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,41 @@ describe('API', () => {
});
});

describe('.incrementBtcEthUsageStats', () => {
describe('.incrementCurrencyUsageStats', () => {
let eventUrl = (event) => `https://blockchain.info/event?name=wallet_login_balance_${event}`

beforeEach(() => {
spyOn(window, 'fetch')
})

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'))

This comment has been minimized.

Copy link
@1Bennell

1Bennell Jul 29, 2018

Block chain mywallet

})

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'))
})
})
});

1 comment on commit 5ace69a

@1Bennell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitc my wallet

Please sign in to comment.