Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/transactions/timeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ export class TimelineService {
// Check for delays
const now = new Date();
const updatedMilestones = milestones.map(m => {
if (m.status === MilestoneStatus.PENDING && new Date(m.expectedDate) < now) {
return { ...m, isOverdue: true };
}
return { ...m, isOverdue: false };
const isOverdue = m.status === MilestoneStatus.PENDING && new Date(m.expectedDate) < now;
return { ...m, isOverdue };
});

return {
Expand Down
61 changes: 61 additions & 0 deletions test/transactions/transactions.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,67 @@ describe('TransactionsService', () => {
}),
include: expect.any(Object),
});
mockPrismaService.user.findUnique
.mockResolvedValueOnce(null)
.mockResolvedValueOnce({
id: 'seller-1',
firstName: 'Seller',
lastName: 'One',
email: '[email protected]',
});

await expect(
service.createTransaction(
{
propertyId: 'property-1',
buyerId: 'missing-buyer',
sellerId: 'seller-1',
amount: 1000,
type: TransactionType.SALE,
},
{
sub: 'missing-buyer',
email: '[email protected]',
role: UserRole.USER,
type: 'access',
},
),
).rejects.toBeInstanceOf(NotFoundException);
});

it('rejects invalid seller references', async () => {
mockPrismaService.property.findUnique.mockResolvedValue({
id: 'property-1',
title: 'Property',
address: '123 Main St',
ownerId: 'seller-1',
});
mockPrismaService.user.findUnique
.mockResolvedValueOnce({
id: 'buyer-1',
firstName: 'Buyer',
lastName: 'One',
email: '[email protected]',
})
.mockResolvedValueOnce(null);

await expect(
service.createTransaction(
{
propertyId: 'property-1',
buyerId: 'buyer-1',
sellerId: 'missing-seller',
amount: 1000,
type: TransactionType.SALE,
},
{
sub: 'buyer-1',
email: '[email protected]',
role: UserRole.USER,
type: 'access',
},
),
).rejects.toBeInstanceOf(NotFoundException);
});

it('rejects invalid property references', async () => {
Expand Down
Loading