39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
|
import { createWrapper, axios } from 'app/test/vitest/helper';
|
|
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
|
|
|
|
describe('CustomerPayments', () => {
|
|
let vm;
|
|
|
|
beforeAll(() => {
|
|
vm = createWrapper(CustomerPayments, {
|
|
global: {
|
|
stubs: ['VnPaginate'],
|
|
mocks: {
|
|
fetch: vi.fn(),
|
|
},
|
|
},
|
|
}).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',
|
|
type: 'positive',
|
|
})
|
|
);
|
|
});
|
|
});
|
|
});
|