updated tests
This commit is contained in:
@@ -13,6 +13,19 @@ jest.mock('../../../services/stripeService', () => ({
|
||||
createRefund: mockCreateRefund
|
||||
}));
|
||||
|
||||
const mockLoggerError = jest.fn();
|
||||
const mockLoggerWarn = jest.fn();
|
||||
jest.mock('../../../utils/logger', () => ({
|
||||
error: mockLoggerError,
|
||||
warn: mockLoggerWarn,
|
||||
info: jest.fn(),
|
||||
withRequestId: jest.fn(() => ({
|
||||
error: jest.fn(),
|
||||
info: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
})),
|
||||
}));
|
||||
|
||||
const RefundService = require('../../../services/refundService');
|
||||
|
||||
describe('RefundService', () => {
|
||||
@@ -540,8 +553,9 @@ describe('RefundService', () => {
|
||||
const result = await RefundService.processCancellation(1, 200);
|
||||
|
||||
expect(mockCreateRefund).not.toHaveBeenCalled();
|
||||
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
||||
'Refund amount calculated but no payment intent ID for rental 1'
|
||||
expect(mockLoggerWarn).toHaveBeenCalledWith(
|
||||
'Refund amount calculated but no payment intent ID for rental',
|
||||
{ rentalId: 1 }
|
||||
);
|
||||
|
||||
expect(result.refund).toEqual({
|
||||
@@ -605,9 +619,9 @@ describe('RefundService', () => {
|
||||
await expect(RefundService.processCancellation(1, 200))
|
||||
.rejects.toThrow('Failed to process refund: Refund failed');
|
||||
|
||||
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
||||
'Error processing Stripe refund:',
|
||||
stripeError
|
||||
expect(mockLoggerError).toHaveBeenCalledWith(
|
||||
'Error processing Stripe refund',
|
||||
expect.objectContaining({ error: stripeError })
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user