Skip to content

Commit

Permalink
refactor(transaction.controller.external.intg.test.ts): reformat code…
Browse files Browse the repository at this point in the history
… for better readability and maintainability

test(transaction.controller.external.intg.test.ts): add test case for when counterparty has both business and end user data, returns 400 status code and appropriate error message
  • Loading branch information
MatanYadaev committed Mar 11, 2024
1 parent 6c77e20 commit 2d586ad
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,34 +542,34 @@ describe('#TransactionControllerExternal', () => {
message: 'Counterparty must have either business or end user data.',
});
});
});

it('returns 400 when counterparty has both business and end user', async () => {
// Arrange
const apiKey = (customer.authenticationConfiguration as { authValue: string }).authValue;
const validTransaction = getBaseTransactionData();
const transactions = [
{
...validTransaction,
originator: getBusinessCounterpartyData(),
beneficiary: {
...getBusinessCounterpartyData(),
...getEndUserCounterpartyData(),
it('returns 400 when counterparty has both business and end user', async () => {
// Arrange
const apiKey = (customer.authenticationConfiguration as { authValue: string }).authValue;
const validTransaction = getBaseTransactionData();
const transactions = [
{
...validTransaction,
originator: getBusinessCounterpartyData(),
beneficiary: {
...getBusinessCounterpartyData(),
...getEndUserCounterpartyData(),
},
},
},
] as const satisfies readonly TransactionCreateDto[];

// Act
const response = await request(app.getHttpServer())
.post('/external/transactions/bulk')
.send(transactions)
.set('authorization', `Bearer ${apiKey}`);

// Assert
expect(response.status).toBe(400);
expect(response.body).toEqual({
statusCode: 400,
message: 'Counterparty must have either business or end user data.',
] as const satisfies readonly TransactionCreateDto[];

// Act
const response = await request(app.getHttpServer())
.post('/external/transactions/bulk')
.send(transactions)
.set('authorization', `Bearer ${apiKey}`);

// Assert
expect(response.status).toBe(400);
expect(response.body).toEqual({
statusCode: 400,
message: 'Counterparty must have either business or end user data.',
});
});
});
});

0 comments on commit 2d586ad

Please sign in to comment.