Migrate profitPill test to vitest

This commit is contained in:
Matthias 2024-04-13 13:02:25 +02:00
parent 4241167770
commit 31dca96dae
3 changed files with 68 additions and 66 deletions

View File

@ -1,64 +0,0 @@
import ProfitPill from './ProfitPill.vue';
describe('ProfitPill.vue', () => {
it('Shows a Green pill with positive profits', () => {
cy.mount(ProfitPill, {
props: {
profitRatio: 0.051,
profitAbs: 0.1,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
cy.get('div').should('have.class', 'profit-pill-profit').should('be.visible');
cy.get('div').should('contain', '5.10%');
cy.get('div').should('contain', '(0.1)');
cy.get('span').should('have.attr', 'title', 'USDT');
});
it('Shows a Red pill with positive profits', () => {
cy.mount(ProfitPill, {
props: {
profitRatio: -0.1,
profitAbs: -0.1,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
cy.get('div').should('not.have.class', 'profit-pill-profit').should('be.visible');
cy.get('div').should('have.class', 'profit-pill').should('be.visible');
cy.get('div').should('contain', '-10.00%');
cy.get('div').should('contain', '(-0.1)');
cy.get('span').should('have.attr', 'title', 'USDT');
});
it('Shows a pill with 0.0 profits.', () => {
cy.mount(ProfitPill, {
props: {
profitRatio: 0.0,
profitAbs: 0.0,
profitDesc: '',
stakeCurrency: 'BTC',
},
});
cy.get('div').should('have.class', 'profit-pill').should('be.visible');
cy.get('div').should('contain', '0.00%');
cy.get('div').should('contain', '(0)');
cy.get('span').should('have.attr', 'title', 'BTC');
});
it('Shows a pill without relative profits.', () => {
cy.mount(ProfitPill, {
props: {
profitRatio: undefined,
profitAbs: 223,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
cy.get('div').should('have.class', 'profit-pill').should('be.visible');
// cy.get('div').should('not.contain', '%');
cy.get('div').should('contain', '223');
cy.get('span').should('have.attr', 'title', 'USDT');
});
});

View File

@ -0,0 +1,66 @@
import ProfitPill from '@/components/general/ProfitPill.vue';
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
describe('ProfitPill.vue', () => {
it('Shows a Green pill with positive profits', () => {
const wrapper = mount(ProfitPill, {
props: {
profitRatio: 0.051,
profitAbs: 0.1,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
expect(wrapper.find('div').classes()).toContain('profit-pill-profit');
expect(wrapper.find('div').text()).toContain('5.10%');
expect(wrapper.find('div').text()).toContain('(0.1)');
expect(wrapper.find('span').element.title).toBe('USDT');
});
it('Shows a Red pill with positive profits', () => {
const wrapper = mount(ProfitPill, {
props: {
profitRatio: -0.1,
profitAbs: -0.1,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
expect(wrapper.get('div').classes()).not.toContain('profit-pill-profit');
expect(wrapper.get('div').classes()).toContain('profit-pill');
expect(wrapper.get('div').text()).toContain('-10.00%');
expect(wrapper.get('div').text()).toContain('(-0.1)');
expect(wrapper.get('span').element.title).toBe('USDT');
});
it('Shows a pill with 0.0 profits.', () => {
const wrapper = mount(ProfitPill, {
props: {
profitRatio: 0.0,
profitAbs: 0.0,
profitDesc: '',
stakeCurrency: 'BTC',
},
});
expect(wrapper.get('div').classes()).toContain('profit-pill');
expect(wrapper.get('div').text()).toContain('0.00%');
expect(wrapper.get('div').text()).toContain('(0)');
expect(wrapper.get('span').element.title).toBe('BTC');
});
it('Shows a pill without relative profits.', () => {
const wrapper = mount(ProfitPill, {
props: {
profitRatio: undefined,
profitAbs: 223,
profitDesc: '',
stakeCurrency: 'USDT',
},
});
expect(wrapper.get('div').classes()).toContain('profit-pill');
expect(wrapper.get('div').text()).not.toContain('%');
expect(wrapper.get('div').text()).toContain('223');
expect(wrapper.get('span').element.title).toBe('USDT');
});
});

View File

@ -1,7 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [
"unit/*.ts",
"unit/*.tsx"
"**/*.ts",
"**/*.tsx"
],
}