updated tests

This commit is contained in:
jackiettran
2026-01-15 18:47:43 -05:00
parent 35d5050286
commit 63385e049c
13 changed files with 256 additions and 201 deletions

View File

@@ -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 })
);
});