Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Hristiyan <[email protected]>
  • Loading branch information
icoxxx committed Jan 21, 2025
1 parent d45d4a9 commit 47bbf00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
notifySyncIndicators,
notifyTransactionAction,
notifyWaitingForSignatures,
getNetwork,
} from '@app/common';
import {
NotificationType,
Expand Down Expand Up @@ -405,6 +406,7 @@ describe('TransactionStatusService', () => {
creatorKey: {
userId: 23,
},
mirrorNetwork: 'testnet',
};
transactionRepo.findOne.mockResolvedValue(transaction as Transaction);

Expand All @@ -413,6 +415,8 @@ describe('TransactionStatusService', () => {

await service.updateTransactionStatus({ id: transaction.id });

const networkString = getNetwork(transaction as Transaction);

expect(transactionRepo.update).toHaveBeenNthCalledWith(
1,
{
Expand All @@ -431,7 +435,7 @@ describe('TransactionStatusService', () => {
entityId: transaction.id,
type: NotificationType.TRANSACTION_READY_FOR_EXECUTION,
actorId: null,
content: `Transaction ${transaction.transactionId} is ready for execution`,
content: `Transaction ${transaction.transactionId} on ${networkString} network is ready for execution!`,
userIds: [transaction.creatorKey?.userId],
});
expect(notifyTransactionAction).toHaveBeenCalledWith(notificationsService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MirrorNodeService,
NotifyForTransactionDto,
NotifyGeneralDto,
getNetwork,
} from '@app/common';
import {
Notification,
Expand Down Expand Up @@ -648,6 +649,7 @@ describe('ReceiverService', () => {
signedTransactions: [],
createdTransactions: [],
},
mirrorNetwork: 'testnet',
};
entityManager.findOne
.calledWith(Transaction, expect.anything())
Expand All @@ -666,6 +668,8 @@ describe('ReceiverService', () => {

await service.notifyTransactionRequiredSigners(dto);

const networkString = getNetwork(transaction as Transaction);

expect(entityManager.findOne).toHaveBeenCalledWith(Transaction, {
where: { id: dto.transactionId },
relations: { creatorKey: true },
Expand All @@ -674,7 +678,7 @@ describe('ReceiverService', () => {
expect(notifyGeneral).toHaveBeenCalledWith({
userIds: usersIdsRequiredToSign.filter(id => id !== creatorId),
type: NotificationType.TRANSACTION_WAITING_FOR_SIGNATURES,
content: `A new transaction requires your review and signature. Please visit the Hedera Transaction Tool and locate the transaction using the following ID: ${transaction.transactionId}.`,
content: `A new transaction submitted on ${networkString} network requires your review and signature. Please visit the Hedera Transaction Tool and locate the transaction using the following ID: ${transaction.transactionId}.`,
entityId: 1,
actorId: null,
});
Expand Down

0 comments on commit 47bbf00

Please sign in to comment.