Skip to content

Commit

Permalink
test: add testing case
Browse files Browse the repository at this point in the history
  • Loading branch information
BZahory committed Aug 21, 2024
1 parent 9774dab commit ab5ba5f
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/transaction-controller/src/utils/swaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,60 @@ describe('updateSwapsTransaction', () => {
swapAndSendRecipient,
});
});

it('should update swap and send approval transaction and publish TransactionController:transactionNewSwapAndSendApproval', async () => {
const sourceTokenSymbol = 'ETH';
const type = TransactionType.swapAndSendApproval;

swaps.meta = {
sourceTokenSymbol,
type,
};
transactionType = TransactionType.swapAndSendApproval;

const transactionNewSwapAndSendApprovalEventListener = jest.fn();
messenger.subscribe(
'TransactionController:transactionNewSwapAndSendApproval',
transactionNewSwapAndSendApprovalEventListener,
);

updateSwapsTransaction(transactionMeta, transactionType, swaps, request);
expect(
transactionNewSwapAndSendApprovalEventListener,
).toHaveBeenCalledTimes(1);
expect(transactionNewSwapAndSendApprovalEventListener).toHaveBeenCalledWith(
{
transactionMeta: {
...transactionMeta,
sourceTokenSymbol,
type,
},
},
);
});

it('should return the swap and send approval transaction updated with information', async () => {
const sourceTokenSymbol = 'ETH';
const type = TransactionType.swapAndSendApproval;

swaps.meta = {
sourceTokenSymbol,
type,
};
transactionType = TransactionType.swapAndSendApproval;

const updatedSwapsTransaction = updateSwapsTransaction(
transactionMeta,
transactionType,
swaps,
request,
);
expect(updatedSwapsTransaction).toStrictEqual({
...transactionMeta,
sourceTokenSymbol,
type,
});
});
});

describe('updatePostTransactionBalance', () => {
Expand Down

0 comments on commit ab5ba5f

Please sign in to comment.