FIx 0.0% not showing profit pill

closes #499
This commit is contained in:
Matthias 2021-10-06 20:33:45 +02:00
parent 9fa15b72f3
commit 3631d52297
2 changed files with 61 additions and 3 deletions

View File

@ -4,10 +4,10 @@
:class="isProfitable ? 'profit-pill-profit' : ''"
:title="profitDesc"
>
{{ profitRatio ? formatPercent(profitRatio, 2) : '' }}
{{ profitRatio !== undefined ? formatPercent(profitRatio, 2) : '' }}
<span class="ml-1" :class="profitRatio ? 'small' : ''" :title="stakeCurrency">
{{ profitRatio ? '(' : '' }}{{ `${formatPrice(profitAbs, 3)}`
}}{{ profitRatio ? ')' : ` ${stakeCurrency}` }}
{{ profitRatio !== undefined ? '(' : '' }}{{ `${formatPrice(profitAbs, 3)}`
}}{{ profitRatio !== undefined ? ')' : ` ${stakeCurrency}` }}
</span>
</div>
</template>

View File

@ -0,0 +1,58 @@
/* eslint-disable @typescript-eslint/camelcase */
import { mount } from '@vue/test-utils';
import Vue from 'vue';
import ProfitPill from '@/components/general/ProfitPill.vue';
describe('ProfitPill.vue', () => {
let cmp;
beforeEach(() => {
cmp = mount(ProfitPill, {
propsData: {
profitRatio: 0,
profitAbs: 0,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
});
it('Shows a Green pill with positive profits', async () => {
const props = {
profitRatio: 0.051,
profitAbs: 0.1,
};
cmp.setProps(props);
await Vue.nextTick();
expect(cmp.html()).toContain('profit-pill-profit');
expect(cmp.html()).toContain('5.10%');
expect(cmp.html()).toContain('(0.1)');
expect(cmp.html()).toContain('title="USDT"');
});
it('Shows a Red pill with positive profits', async () => {
const props = {
profitRatio: -0.1,
profitAbs: -0.1,
stakeCurrency: 'USDT',
};
cmp.setProps(props);
await Vue.nextTick();
expect(cmp.html()).not.toContain('profit-pill-profit');
expect(cmp.html()).toContain('profit-pill');
expect(cmp.html()).toContain('(-0.1)');
expect(cmp.html()).toContain('-10.00%');
expect(cmp.html()).toContain('title="USDT"');
});
it('Shows a pill with 0.0 profits.', async () => {
const props = {
profitRatio: 0.0,
profitAbs: 0.0,
stakeCurrency: 'BTC',
};
cmp.setProps(props);
await Vue.nextTick();
expect(cmp.html()).toContain('profit-pill');
expect(cmp.html()).toContain('0.00%');
expect(cmp.html()).toContain('(0)');
expect(cmp.html()).toContain('title="BTC"');
});
});