2023-03-21 08:50:03 +00:00
|
|
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
|
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
2023-12-28 15:25:23 +00:00
|
|
|
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
|
2023-03-21 08:50:03 +00:00
|
|
|
|
|
|
|
describe('CustomerPayments', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
vm = createWrapper(CustomerPayments, {
|
|
|
|
global: {
|
2023-04-11 11:31:03 +00:00
|
|
|
stubs: ['VnPaginate'],
|
2023-03-21 08:50:03 +00:00
|
|
|
mocks: {
|
|
|
|
fetch: vi.fn(),
|
|
|
|
},
|
2023-12-28 15:25:23 +00:00
|
|
|
},
|
2023-03-21 08:50:03 +00:00
|
|
|
}).vm;
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vi.clearAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('confirmTransaction()', () => {
|
|
|
|
it('should make a POST request and then call to quasar notify method', async () => {
|
|
|
|
vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
|
|
|
|
vi.spyOn(vm.quasar, 'notify');
|
|
|
|
|
|
|
|
await vm.confirmTransaction({ id: 1 });
|
|
|
|
|
|
|
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
|
|
|
expect.objectContaining({
|
|
|
|
message: 'Payment confirmed',
|
2023-12-28 15:25:23 +00:00
|
|
|
type: 'positive',
|
2023-03-21 08:50:03 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|