Skip to content

Commit

Permalink
update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
carolk-dev committed Dec 20, 2024
1 parent 16e1379 commit 6f8167c
Showing 1 changed file with 66 additions and 66 deletions.
132 changes: 66 additions & 66 deletions bridge/test/pending-transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,80 @@ import { PendingTransactionMessage } from "../src/messages/pending-transaction-m
import { TransactionStatus } from "../src/types/transaction-status";

describe("PendingTransactionHandler", () => {
let exchangeHistoryStore: jest.Mocked<IExchangeHistoryStore>;
let ncgTransfer: jest.Mocked<INCGTransfer>;
let multiPlanetary: jest.Mocked<MultiPlanetary>;
let slackMessageSender: jest.Mocked<ISlackMessageSender>;
let handler: PendingTransactionHandler;
let exchangeHistoryStore: jest.Mocked<IExchangeHistoryStore>;
let ncgTransfer: jest.Mocked<INCGTransfer>;
let multiPlanetary: jest.Mocked<MultiPlanetary>;
let slackMessageSender: jest.Mocked<ISlackMessageSender>;
let handler: PendingTransactionHandler;

beforeEach(() => {
exchangeHistoryStore = {
getPendingTransactions: jest.fn(),
updateStatus: jest.fn(),
} as unknown as jest.Mocked<IExchangeHistoryStore>;
beforeEach(() => {
exchangeHistoryStore = {
getPendingTransactions: jest.fn(),
updateStatus: jest.fn(),
} as unknown as jest.Mocked<IExchangeHistoryStore>;

ncgTransfer = {} as jest.Mocked<INCGTransfer>;
multiPlanetary = {} as jest.Mocked<MultiPlanetary>;
slackMessageSender = {
sendMessage: jest.fn(),
} as unknown as jest.Mocked<ISlackMessageSender>;
ncgTransfer = {} as jest.Mocked<INCGTransfer>;
multiPlanetary = {} as jest.Mocked<MultiPlanetary>;
slackMessageSender = {
sendMessage: jest.fn(),
} as unknown as jest.Mocked<ISlackMessageSender>;

handler = new PendingTransactionHandler(
exchangeHistoryStore,
ncgTransfer,
multiPlanetary,
slackMessageSender
);
});
handler = new PendingTransactionHandler(
exchangeHistoryStore,
ncgTransfer,
multiPlanetary,
slackMessageSender
);
});

it("should send a message for pending transactions and update their status", async () => {
const pendingTransactions = [
{
tx_id: "TX-1",
network: "ethereum",
amount: 100,
sender: "sender1",
recipient: "recipient1",
timestamp: new Date().toISOString(),
status: TransactionStatus.PENDING,
},
{
tx_id: "TX-2",
network: "nineChronicles",
amount: 200,
sender: "sender2",
recipient: "recipient2",
timestamp: new Date().toISOString(),
status: TransactionStatus.PENDING,
},
];
it("should send a message for pending transactions and update their status", async () => {
const pendingTransactions = [
{
tx_id: "TX-1",
network: "ethereum",
amount: 100,
sender: "sender1",
recipient: "recipient1",
timestamp: new Date().toISOString(),
status: TransactionStatus.PENDING,
},
{
tx_id: "TX-2",
network: "nineChronicles",
amount: 200,
sender: "sender2",
recipient: "recipient2",
timestamp: new Date().toISOString(),
status: TransactionStatus.PENDING,
},
];

exchangeHistoryStore.getPendingTransactions.mockResolvedValue(
pendingTransactions
);
exchangeHistoryStore.getPendingTransactions.mockResolvedValue(
pendingTransactions
);

await handler.messagePendingTransactions();
await handler.messagePendingTransactions();

expect(slackMessageSender.sendMessage).toHaveBeenCalledWith(
expect.any(PendingTransactionMessage)
);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledTimes(2);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledWith(
"TX-1",
TransactionStatus.FAILED
);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledWith(
"TX-2",
TransactionStatus.FAILED
);
});
expect(slackMessageSender.sendMessage).toHaveBeenCalledWith(
expect.any(PendingTransactionMessage)
);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledTimes(2);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledWith(
"TX-1",
TransactionStatus.FAILED
);
expect(exchangeHistoryStore.updateStatus).toHaveBeenCalledWith(
"TX-2",
TransactionStatus.FAILED
);
});

it("should not send a message if there are no pending transactions", async () => {
exchangeHistoryStore.getPendingTransactions.mockResolvedValue([]);
it("should not send a message if there are no pending transactions", async () => {
exchangeHistoryStore.getPendingTransactions.mockResolvedValue([]);

await handler.messagePendingTransactions();
await handler.messagePendingTransactions();

expect(slackMessageSender.sendMessage).not.toHaveBeenCalled();
expect(exchangeHistoryStore.updateStatus).not.toHaveBeenCalled();
});
expect(slackMessageSender.sendMessage).not.toHaveBeenCalled();
expect(exchangeHistoryStore.updateStatus).not.toHaveBeenCalled();
});
});

0 comments on commit 6f8167c

Please sign in to comment.