schema updates to rental statuses

This commit is contained in:
jackiettran
2025-11-24 18:08:12 -05:00
parent 42a5412582
commit 8e6af92cba
7 changed files with 19 additions and 34 deletions

View File

@@ -186,11 +186,6 @@ describe('PayoutService', () => {
it('should successfully process a rental payout', async () => {
const result = await PayoutService.processRentalPayout(mockRental);
// Verify status update to processing
expect(mockRental.update).toHaveBeenNthCalledWith(1, {
payoutStatus: 'processing'
});
// Verify Stripe transfer creation
expect(mockCreateTransfer).toHaveBeenCalledWith({
amount: 9500,
@@ -206,7 +201,7 @@ describe('PayoutService', () => {
});
// Verify status update to completed
expect(mockRental.update).toHaveBeenNthCalledWith(2, {
expect(mockRental.update).toHaveBeenCalledWith({
payoutStatus: 'completed',
payoutProcessedAt: expect.any(Date),
stripeTransferId: 'tr_123456789'
@@ -260,13 +255,8 @@ describe('PayoutService', () => {
await expect(PayoutService.processRentalPayout(mockRental))
.rejects.toThrow('Stripe transfer failed');
// Verify processing status was set
expect(mockRental.update).toHaveBeenNthCalledWith(1, {
payoutStatus: 'processing'
});
// Verify failure status was set
expect(mockRental.update).toHaveBeenNthCalledWith(2, {
expect(mockRental.update).toHaveBeenCalledWith({
payoutStatus: 'failed'
});
@@ -296,9 +286,7 @@ describe('PayoutService', () => {
});
const dbError = new Error('Database completion update failed');
mockRental.update
.mockResolvedValueOnce(true) // processing update succeeds
.mockRejectedValueOnce(dbError); // completion update fails
mockRental.update.mockRejectedValueOnce(dbError);
await expect(PayoutService.processRentalPayout(mockRental))
.rejects.toThrow('Database completion update failed');
@@ -315,16 +303,14 @@ describe('PayoutService', () => {
const updateError = new Error('Update failed status failed');
mockCreateTransfer.mockRejectedValue(stripeError);
mockRental.update
.mockResolvedValueOnce(true) // processing update succeeds
.mockRejectedValueOnce(updateError); // failed status update fails
mockRental.update.mockRejectedValueOnce(updateError);
// The service will throw the update error since it happens in the catch block
await expect(PayoutService.processRentalPayout(mockRental))
.rejects.toThrow('Update failed status failed');
// Should still attempt to update to failed status
expect(mockRental.update).toHaveBeenNthCalledWith(2, {
expect(mockRental.update).toHaveBeenCalledWith({
payoutStatus: 'failed'
});
});