frequi_origin/tests/unit/ProfitSymbol.spec.ts

49 lines
1.3 KiB
TypeScript
Raw Normal View History

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(() => {
cmp = mount(ProfitSymbol, { propsData: { trade: {} } });
});
2021-02-08 09:52:12 +00:00
it('calculates isProfitable with negative profit', async () => {
2020-11-20 07:02:24 +00:00
const trade = {
profit_ratio: -0.5,
};
cmp.setProps({ trade });
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 () => {
2020-11-20 07:02:24 +00:00
const trade = {
profit_ratio: 0.5,
};
cmp.setProps({ trade });
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 () => {
const trade = {
profit_ratio: -0.5,
};
cmp.setProps({ trade });
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 () => {
const trade = {
profit_ratio: 0.5,
};
cmp.setProps({ trade });
await Vue.nextTick();
expect(cmp.html()).toContain('triangle-up');
expect(cmp.html()).not.toContain('triangle-down');
});
});