From 2d7c64e4075bc5984e4521821207985f69c5e99a Mon Sep 17 00:00:00 2001 From: brenopolanski Date: Wed, 29 Jan 2020 17:12:48 -0300 Subject: [PATCH 1/4] fix: add truncate filter to the wallet balance in the profile --- src/renderer/pages/Profile/ProfileAll.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/Profile/ProfileAll.vue b/src/renderer/pages/Profile/ProfileAll.vue index 8e042b1e76..d04902b3cc 100644 --- a/src/renderer/pages/Profile/ProfileAll.vue +++ b/src/renderer/pages/Profile/ProfileAll.vue @@ -38,7 +38,7 @@ - {{ profileBalance(profile) }} + {{ profileBalance(profile) | truncate(15) }} Date: Mon, 10 Feb 2020 17:25:26 -0300 Subject: [PATCH 2/4] test: add tests for truncated balances --- .../unit/pages/Profile/ProfileAll.spec.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) mode change 100644 => 100755 __tests__/unit/pages/Profile/ProfileAll.spec.js diff --git a/__tests__/unit/pages/Profile/ProfileAll.spec.js b/__tests__/unit/pages/Profile/ProfileAll.spec.js old mode 100644 new mode 100755 index c1d2ba19a6..2f177aa81b --- a/__tests__/unit/pages/Profile/ProfileAll.spec.js +++ b/__tests__/unit/pages/Profile/ProfileAll.spec.js @@ -1,14 +1,17 @@ import { createLocalVue, mount } from '@vue/test-utils' import VueRouter from 'vue-router' +import { uniqBy } from 'lodash' import { useI18n } from '../../__utils__/i18n' import router from '@/router' import CurrencyMixin from '@/mixins/currency' +import truncate from '@/filters/truncate' import ProfileAll from '@/pages/Profile/ProfileAll' import BigNumber from '@/plugins/bignumber.js' const localVue = createLocalVue() const i18n = useI18n(localVue) localVue.use(VueRouter) +localVue.filter('truncate', truncate) describe('pages > ProfileAll', () => { let wrapper @@ -36,7 +39,11 @@ describe('pages > ProfileAll', () => { 'network/byToken': token => networkBy('token', token), 'network/bySymbol': symbol => networkBy('symbol', symbol), 'profile/all': profiles, - 'profile/balanceWithLedger': _id => new BigNumber(13700000), + 'profile/balanceWithLedger': id => { + return uniqBy(wallets[id], 'address').reduce((total, wallet) => { + return new BigNumber(wallet.balance).plus(total) + }, 0) + }, 'wallet/byProfileId': id => wallets[id] } }, @@ -169,7 +176,17 @@ describe('pages > ProfileAll', () => { describe('profileBalance', () => { it('should return the formatted balance of a profile, using the network symbol', () => { wrapper = mountPage() - expect(wrapper.vm.profileBalance(profiles[0])).toEqual('m\xa00.137') + expect(wrapper.vm.profileBalance(profiles[0])).toEqual('m\xa00.150909') + }) + + describe('when the `truncate` is passed', () => { + it('should return the balance, but truncated', () => { + wrapper = mountPage() + expect(truncate(wrapper.vm.profileBalance(profiles[0]), 8)).toEqual('m\xa00.1509…') + expect(truncate(wrapper.vm.profileBalance(profiles[1]), 6)).toEqual('o\xa00.12…') + expect(truncate(wrapper.vm.profileBalance(profiles[2]), 3)).toEqual('m\xa05…') + expect(truncate(wrapper.vm.profileBalance(profiles[3]), 5)).toEqual('d\xa00.5…') + }) }) }) }) From 919230faa5e0d8979afea63e0367014b8904f1ce Mon Sep 17 00:00:00 2001 From: brenopolanski Date: Wed, 12 Feb 2020 14:13:48 -0300 Subject: [PATCH 3/4] refactor: add truncate class in profile balance --- src/renderer/pages/Profile/ProfileAll.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/pages/Profile/ProfileAll.vue b/src/renderer/pages/Profile/ProfileAll.vue index d04902b3cc..a51f3fea10 100644 --- a/src/renderer/pages/Profile/ProfileAll.vue +++ b/src/renderer/pages/Profile/ProfileAll.vue @@ -37,8 +37,8 @@ {{ profile.name | truncate(12) }} - - {{ profileBalance(profile) | truncate(15) }} + + {{ profileBalance(profile) }} Date: Wed, 12 Feb 2020 14:34:06 -0300 Subject: [PATCH 4/4] test: remove truncated tests --- .../unit/pages/Profile/ProfileAll.spec.js | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/__tests__/unit/pages/Profile/ProfileAll.spec.js b/__tests__/unit/pages/Profile/ProfileAll.spec.js index 2f177aa81b..c1d2ba19a6 100755 --- a/__tests__/unit/pages/Profile/ProfileAll.spec.js +++ b/__tests__/unit/pages/Profile/ProfileAll.spec.js @@ -1,17 +1,14 @@ import { createLocalVue, mount } from '@vue/test-utils' import VueRouter from 'vue-router' -import { uniqBy } from 'lodash' import { useI18n } from '../../__utils__/i18n' import router from '@/router' import CurrencyMixin from '@/mixins/currency' -import truncate from '@/filters/truncate' import ProfileAll from '@/pages/Profile/ProfileAll' import BigNumber from '@/plugins/bignumber.js' const localVue = createLocalVue() const i18n = useI18n(localVue) localVue.use(VueRouter) -localVue.filter('truncate', truncate) describe('pages > ProfileAll', () => { let wrapper @@ -39,11 +36,7 @@ describe('pages > ProfileAll', () => { 'network/byToken': token => networkBy('token', token), 'network/bySymbol': symbol => networkBy('symbol', symbol), 'profile/all': profiles, - 'profile/balanceWithLedger': id => { - return uniqBy(wallets[id], 'address').reduce((total, wallet) => { - return new BigNumber(wallet.balance).plus(total) - }, 0) - }, + 'profile/balanceWithLedger': _id => new BigNumber(13700000), 'wallet/byProfileId': id => wallets[id] } }, @@ -176,17 +169,7 @@ describe('pages > ProfileAll', () => { describe('profileBalance', () => { it('should return the formatted balance of a profile, using the network symbol', () => { wrapper = mountPage() - expect(wrapper.vm.profileBalance(profiles[0])).toEqual('m\xa00.150909') - }) - - describe('when the `truncate` is passed', () => { - it('should return the balance, but truncated', () => { - wrapper = mountPage() - expect(truncate(wrapper.vm.profileBalance(profiles[0]), 8)).toEqual('m\xa00.1509…') - expect(truncate(wrapper.vm.profileBalance(profiles[1]), 6)).toEqual('o\xa00.12…') - expect(truncate(wrapper.vm.profileBalance(profiles[2]), 3)).toEqual('m\xa05…') - expect(truncate(wrapper.vm.profileBalance(profiles[3]), 5)).toEqual('d\xa00.5…') - }) + expect(wrapper.vm.profileBalance(profiles[0])).toEqual('m\xa00.137') }) }) })