Refactor: Update error messages in user routes tests for clarity and consistency
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 11m44s
All checks were successful
Deploy to Test Environment / deploy-to-test (push) Successful in 11m44s
This commit is contained in:
@@ -249,10 +249,11 @@ describe('Flyer DB Service', () => {
|
||||
mockClient.query
|
||||
.mockResolvedValueOnce({ rows: [{ store_id: 1 }] }) // findOrCreateStore
|
||||
.mockRejectedValueOnce(dbError); // insertFlyer fails
|
||||
// The withTransaction helper will catch this and roll back
|
||||
await expect(callback(mockClient as unknown as PoolClient)).rejects.toThrow(dbError);
|
||||
// re-throw because withTransaction re-throws
|
||||
throw dbError;
|
||||
// The withTransaction helper will catch this and roll back.
|
||||
// Since insertFlyer wraps the DB error, we expect the wrapped error message here.
|
||||
await expect(callback(mockClient as unknown as PoolClient)).rejects.toThrow('Failed to insert flyer into database.');
|
||||
// re-throw because withTransaction re-throws (simulating the wrapped error propagating up)
|
||||
throw new Error('Failed to insert flyer into database.');
|
||||
});
|
||||
|
||||
// The transactional function re-throws the original error from the failed step.
|
||||
|
||||
Reference in New Issue
Block a user