optimized condition checks

This commit is contained in:
jackiettran
2026-01-06 17:28:20 -05:00
parent 28c0b4976d
commit 1203fb7996
9 changed files with 275 additions and 401 deletions

View File

@@ -122,44 +122,4 @@ describe('ConditionCheckService', () => {
).rejects.toThrow('Rental not found');
});
});
describe('getConditionChecks', () => {
it('should retrieve condition checks for rental', async () => {
const mockChecks = [
{
id: 'check-1',
checkType: 'pre_rental_owner',
submittedBy: 'owner-456',
submittedAt: '2023-05-31T12:00:00Z',
photos: ['/uploads/photo1.jpg'],
notes: 'Item ready'
},
{
id: 'check-2',
checkType: 'rental_start_renter',
submittedBy: 'renter-789',
submittedAt: '2023-06-01T11:00:00Z',
photos: ['/uploads/photo2.jpg'],
notes: 'Item received'
}
];
ConditionCheck.findAll.mockResolvedValue(mockChecks);
const result = await ConditionCheckService.getConditionChecks('rental-123');
expect(ConditionCheck.findAll).toHaveBeenCalledWith({
where: { rentalId: 'rental-123' },
include: [{
model: User,
as: 'submittedByUser',
attributes: ['id', 'firstName', 'lastName']
}],
order: [['submittedAt', 'ASC']]
});
expect(result).toEqual(mockChecks);
expect(result.length).toBe(2);
});
});
});