optimized condition checks
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user