51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue';
|
|
|
|
describe('ClaimLinesImport', () => {
|
|
let vm;
|
|
|
|
|
|
beforeAll(() => {
|
|
vm = createWrapper(ClaimLinesImport, {
|
|
global: {
|
|
stubs: ['FetchData'],
|
|
mocks: {
|
|
fetch: vi.fn(),
|
|
},
|
|
}
|
|
}).vm;
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
describe('importLines()', () => {
|
|
it('should make a POST request and then call to the quasar notify() method', async () => {
|
|
vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
|
|
vi.spyOn(vm.quasar, 'notify');
|
|
|
|
vm.selected = [
|
|
{ id: 1, saleFk: 1, claimFk: 1, quantity: 10 }
|
|
]
|
|
|
|
vm.route.params.id = 1
|
|
|
|
await vm.importLines();
|
|
const expectedData = [{ saleFk: 1, claimFk: 1, quantity: 10 }]
|
|
|
|
expect(axios.post).toHaveBeenCalledWith('ClaimBeginnings', expectedData, {
|
|
signal: expect.any(Object)
|
|
})
|
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
message: 'Lines added to claim',
|
|
type: 'positive'
|
|
})
|
|
);
|
|
expect(vm.canceller).toEqual(null)
|
|
});
|
|
});
|
|
});
|