2023-11-09 09:29:28 +00:00
|
|
|
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
2024-05-28 11:11:38 +00:00
|
|
|
import { createWrapper } from 'app/test/vitest/helper';
|
2023-11-09 09:29:28 +00:00
|
|
|
import InvoiceInVat from 'src/pages/InvoiceIn/Card/InvoiceInVat.vue';
|
|
|
|
|
|
|
|
describe('InvoiceInVat', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
vm = createWrapper(InvoiceInVat, {
|
|
|
|
global: {
|
|
|
|
stubs: [],
|
|
|
|
mocks: {
|
|
|
|
fetch: vi.fn(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).vm;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('taxRate()', () => {
|
|
|
|
it('should correctly compute the tax rate', () => {
|
2023-12-12 11:11:45 +00:00
|
|
|
const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
|
2023-11-09 09:29:28 +00:00
|
|
|
vm.sageTaxTypes = [
|
|
|
|
{ id: 1, rate: 10 },
|
|
|
|
{ id: 2, rate: 20 },
|
|
|
|
];
|
2023-12-12 11:11:45 +00:00
|
|
|
const result = vm.taxRate(invoiceInTax);
|
2023-11-09 09:29:28 +00:00
|
|
|
expect(result).toBe((10 / 100) * 100);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return 0 if there is not tax rate', () => {
|
2023-12-12 11:11:45 +00:00
|
|
|
const invoiceInTax = { taxableBase: 100, taxTypeSageFk: 1 };
|
2023-11-09 09:29:28 +00:00
|
|
|
vm.sageTaxTypes = [];
|
|
|
|
|
2023-12-12 11:11:45 +00:00
|
|
|
const result = vm.taxRate(invoiceInTax);
|
2023-11-09 09:29:28 +00:00
|
|
|
expect(result).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|