2023-11-06 15:03:36 +00:00
|
|
|
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
|
|
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
|
|
import InvoiceInBasicData from 'src/pages/InvoiceIn/Card/InvoiceInBasicData.vue';
|
|
|
|
|
|
|
|
describe('InvoiceInBasicData', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
vm = createWrapper(InvoiceInBasicData, {
|
|
|
|
global: {
|
|
|
|
stubs: [],
|
|
|
|
mocks: {
|
|
|
|
fetch: vi.fn(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).vm;
|
|
|
|
});
|
|
|
|
|
2023-11-09 09:29:28 +00:00
|
|
|
describe('edit()', () => {
|
|
|
|
it('should throw an error when data is empty', async () => {
|
|
|
|
vi.spyOn(axios, 'post').mockResolvedValue({ data: [] });
|
|
|
|
vi.spyOn(vm.quasar, 'notify');
|
|
|
|
|
|
|
|
await vm.edit();
|
|
|
|
|
|
|
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
|
|
|
message: `The company can't be empty`,
|
|
|
|
type: 'negative',
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2023-11-06 15:03:36 +00:00
|
|
|
});
|
|
|
|
|
2023-11-09 09:29:28 +00:00
|
|
|
describe('create()', () => {
|
|
|
|
it('should throw an error when data is empty', async () => {
|
|
|
|
vi.spyOn(axios, 'post').mockResolvedValue({ data: [] });
|
|
|
|
vi.spyOn(vm.quasar, 'notify');
|
2023-11-06 15:03:36 +00:00
|
|
|
|
2023-11-09 09:29:28 +00:00
|
|
|
await vm.create();
|
2023-11-06 15:03:36 +00:00
|
|
|
|
2023-11-09 09:29:28 +00:00
|
|
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
|
|
|
message: `The company can't be empty`,
|
|
|
|
type: 'negative',
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
2023-11-06 15:03:36 +00:00
|
|
|
});
|
|
|
|
});
|