salix-front/test/vitest/__tests__/pages/InvoiceIn/InvoiceInIntrastat.spec.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-11-09 09:29:28 +00:00
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(() => {
vm = createWrapper(InvoiceInIntrastat, {
global: {
2023-11-22 09:08:51 +00:00
stubs: ['vnPaginate'],
2023-11-09 09:29:28 +00:00
mocks: {
fetch: vi.fn(),
},
},
}).vm;
2023-11-22 09:08:51 +00:00
vi.spyOn(axios, 'get').mockResolvedValue({ data: [{}] });
2023-11-09 09:29:28 +00:00
});
describe('getTotal()', () => {
it('should correctly handle the sum', () => {
2024-05-23 12:19:39 +00:00
const invoceInIntrastat = [
2023-11-09 09:29:28 +00:00
{ amount: 10, stems: 162 },
{ amount: 20, stems: 21 },
];
2024-05-23 12:19:39 +00:00
const totalAmount = vm.getTotal(invoceInIntrastat, 'amount');
const totalStems = vm.getTotal(invoceInIntrastat, 'stems');
2023-11-09 09:29:28 +00:00
expect(totalAmount).toBe(10 + 20);
expect(totalStems).toBe(162 + 21);
});
});
});