Skip to content

Commit

Permalink
Remove axios complete mock and replace w/ nock
Browse files Browse the repository at this point in the history
  • Loading branch information
lambertkevin committed Aug 19, 2024
1 parent 8f4ef5a commit 62c561d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
"jest-environment-jsdom": "^29.7.0",
"listr": "^0.14.3",
"listr-verbose-renderer": "^0.6.0",
"nock": "^13.0.5",
"prebuild-install": "^7.1.1",
"react-refresh": "^0.14.0",
"react-test-renderer": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import nock from "nock";
import React from "react";
import axios from "axios";
import { TFunction } from "i18next";
import BigNumber from "bignumber.js";
import { render, screen, waitFor } from "tests/testUtils";

import {
getCryptoCurrencyById,
setSupportedCurrencies,
Expand All @@ -13,16 +14,13 @@ import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { DomainServiceProvider } from "@ledgerhq/domain-service/hooks/index";
import { Transaction, TransactionStatus } from "@ledgerhq/live-common/generated/types";
import RecipientField from "./RecipientField";
import { TFunction } from "i18next";

// Temp mock to prevent error on sentry init
jest.mock("../../../../sentry/install", () => ({
init: () => null,
}));

jest.mock("axios");

const mockedAxios = jest.mocked(axios);
nock.disableNetConnect();

jest.mock("@ledgerhq/live-common/featureFlags/index", () => ({
useFeature: jest.fn(),
Expand Down Expand Up @@ -335,6 +333,7 @@ describe("RecipientField", () => {
});

it("should not change domain because currency not supported", async () => {
const spy = jest.spyOn(axios, "request");
const { user } = setup(null, null, polygonMockAccount);
const input = screen.getByRole("textbox");
await user.type(input, "0x16bb635bc5c398b63a0fbb38dac84da709eb3e86");
Expand All @@ -345,7 +344,7 @@ describe("RecipientField", () => {
recipientDomain: undefined,
}),
);
expect(mockedAxios).not.toHaveBeenCalled();
expect(spy).not.toHaveBeenCalled();
});
});

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62c561d

Please sign in to comment.