Skip to content

Commit 996b4cb

Browse files
Closes #703: Add coverage for DisputeRepository.resolve default state and not-found path (#708)
Added two new test cases to test/unit/dispute.repository.spec.ts: - Test resolve() with default escrowState parameter (COMPLETED) - Test resolve() throws when dispute not found The existing test already covered resolve() with explicit non-default escrowState (RELEASED). These additions ensure branch coverage for dispute.repository.ts exceeds 85%. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 1d5784e commit 996b4cb

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/unit/dispute.repository.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,39 @@ describe('DisputeRepository (issue #14)', () => {
118118
expect.objectContaining({ status: 'RESOLVED' }),
119119
);
120120
});
121+
122+
it('resolves the dispute with default escrowState (COMPLETED)', async () => {
123+
const escrow = await prisma.escrow.create({
124+
data: {
125+
itemName: 'Laptop',
126+
itemRef: 'ref-laptop',
127+
amount: 500,
128+
currency: 'USDC',
129+
buyerAddress: 'buyer-1',
130+
vendorAddress: 'vendor-1',
131+
state: 'SHIPPED',
132+
trackingId: 'TRK-10',
133+
},
134+
});
135+
const dispute = await disputeRepository.create({
136+
escrowId: escrow.id,
137+
reason: 'Defective product',
138+
});
139+
140+
// Call resolve without the escrowState parameter to test the default
141+
await disputeRepository.resolve(dispute.id);
142+
143+
const updatedEscrow = await escrowRepository.findById(escrow.id);
144+
expect(updatedEscrow?.state).toBe('COMPLETED');
145+
expect(updatedEscrow?.disputeId).toBeNull();
146+
await expect(disputeRepository.findById(dispute.id)).resolves.toEqual(
147+
expect.objectContaining({ status: 'RESOLVED' }),
148+
);
149+
});
150+
151+
it('throws when resolving a non-existent dispute', async () => {
152+
await expect(disputeRepository.resolve('non-existent-dispute-id')).rejects.toThrow(
153+
'Dispute non-existent-dispute-id not found',
154+
);
155+
});
121156
});

0 commit comments

Comments
 (0)