Skip to content

Commit

Permalink
fix: delegations tests (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
totraev authored Sep 25, 2024
1 parent 7ba30bc commit ea459b9
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/utils/local_storage/filterDelegationsLocalStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ describe("utils/local_storage/filterDelegationsLocalStorage", () => {
});

it("should return valid delegations not present in the API and not exceeding the max duration", async () => {
(getTxInfo as jest.Mock).mockRejectedValue(
new Error("Transaction not found in the mempool"),
);
(getTxInfo as jest.Mock).mockRejectedValue({
message: "Transaction not found in the mempool",
code: 404,
});

const result = await filterDelegationsLocalStorage(
mockDelegationsLocalStorage,
Expand All @@ -49,9 +50,10 @@ describe("utils/local_storage/filterDelegationsLocalStorage", () => {
});

it("should remove delegations that exceed max duration and are not in the mempool", async () => {
(getTxInfo as jest.Mock).mockRejectedValue(
new Error("Transaction not found in the mempool"),
);
(getTxInfo as jest.Mock).mockRejectedValue({
message: "Transaction not found in the mempool",
code: 404,
});

const result = await filterDelegationsLocalStorage(
mockDelegationsLocalStorage,
Expand All @@ -72,9 +74,10 @@ describe("utils/local_storage/filterDelegationsLocalStorage", () => {
if (txHash === "hash1" || txHash === "hash3" || txHash === "hash6") {
return Promise.resolve({});
} else {
return Promise.reject(
new Error("Transaction not found in the mempool"),
);
return Promise.reject({
message: "Transaction not found in the mempool",
code: 404,
});
}
});

Expand Down Expand Up @@ -132,9 +135,10 @@ describe("utils/local_storage/filterDelegationsLocalStorage", () => {
});

it("should handle no API data but local storage items are present", async () => {
(getTxInfo as jest.Mock).mockRejectedValue(
new Error("Transaction not found in the mempool"),
);
(getTxInfo as jest.Mock).mockRejectedValue({
message: "Transaction not found in the mempool",
code: 404,
});

const result = await filterDelegationsLocalStorage(
mockDelegationsLocalStorage,
Expand Down

0 comments on commit ea459b9

Please sign in to comment.