2020-11-20 07:02:24 +00:00
|
|
|
/* eslint-disable @typescript-eslint/camelcase */
|
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import ProfitSymbol from '@/components/ftbot/ProfitSymbol.vue';
|
|
|
|
|
|
|
|
describe('ProfitSymbol.vue', () => {
|
|
|
|
let cmp;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-10-24 13:11:55 +00:00
|
|
|
cmp = mount(ProfitSymbol, { propsData: { profit: 0 } });
|
2020-11-20 07:02:24 +00:00
|
|
|
});
|
2021-02-08 09:52:12 +00:00
|
|
|
it('calculates isProfitable with negative profit', async () => {
|
2021-10-24 13:11:55 +00:00
|
|
|
const profit = -0.5;
|
|
|
|
cmp.setProps({ profit });
|
2021-02-08 09:52:12 +00:00
|
|
|
await Vue.nextTick();
|
2020-11-20 07:02:24 +00:00
|
|
|
expect(cmp.vm.isProfitable).toBe(false);
|
|
|
|
});
|
2021-02-08 09:52:12 +00:00
|
|
|
it('calculates isProfitable with positive profit', async () => {
|
2021-10-24 13:11:55 +00:00
|
|
|
const profit = 0.5;
|
|
|
|
cmp.setProps({ profit });
|
2021-02-08 09:52:12 +00:00
|
|
|
await Vue.nextTick();
|
2020-11-20 07:02:24 +00:00
|
|
|
expect(cmp.vm.isProfitable).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders triangle down when profit is negative', async () => {
|
2021-10-24 13:11:55 +00:00
|
|
|
const profit = -0.5;
|
|
|
|
cmp.setProps({ profit });
|
2020-11-20 07:02:24 +00:00
|
|
|
await Vue.nextTick();
|
|
|
|
expect(cmp.html()).toContain('triangle-down');
|
|
|
|
expect(cmp.html()).not.toContain('triangle-up');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders triangle up when profit is positive', async () => {
|
2021-10-24 13:11:55 +00:00
|
|
|
const profit = 0.5;
|
|
|
|
cmp.setProps({ profit });
|
2020-11-20 07:02:24 +00:00
|
|
|
await Vue.nextTick();
|
|
|
|
expect(cmp.html()).toContain('triangle-up');
|
|
|
|
expect(cmp.html()).not.toContain('triangle-down');
|
|
|
|
});
|
|
|
|
});
|