35 lines
1021 B
JavaScript
35 lines
1021 B
JavaScript
|
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
||
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||
|
import InvoiceInIntrastat from 'src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue';
|
||
|
|
||
|
describe('InvoiceInIntrastat', () => {
|
||
|
let vm;
|
||
|
|
||
|
beforeAll(() => {
|
||
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
|
||
|
vm = createWrapper(InvoiceInIntrastat, {
|
||
|
global: {
|
||
|
stubs: [],
|
||
|
mocks: {
|
||
|
fetch: vi.fn(),
|
||
|
},
|
||
|
},
|
||
|
}).vm;
|
||
|
});
|
||
|
|
||
|
describe('getTotal()', () => {
|
||
|
it('should correctly handle the sum', () => {
|
||
|
vm.invoceInIntrastat = [
|
||
|
{ amount: 10, stems: 162 },
|
||
|
{ amount: 20, stems: 21 },
|
||
|
];
|
||
|
|
||
|
const totalAmount = vm.getTotal('amount');
|
||
|
const totalStems = vm.getTotal('stems');
|
||
|
|
||
|
expect(totalAmount).toBe(10 + 20);
|
||
|
expect(totalStems).toBe(162 + 21);
|
||
|
});
|
||
|
});
|
||
|
});
|