Skip to content

Commit

Permalink
fix(core): fix unit test case (#4081)
Browse files Browse the repository at this point in the history
  • Loading branch information
fullstackninja864 authored Oct 19, 2023
1 parent 4e73841 commit feca52c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mobile-app/app/components/HeaderTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RootState } from "@store";
import { block } from "@waveshq/walletkit-ui/dist/store/block";
import { HeaderTitle } from "./HeaderTitle";

jest.mock("@contexts/CustomServiceProvider");
jest.mock("@react-navigation/native", () => ({
useNavigation: jest.fn(),
}));
Expand Down Expand Up @@ -45,7 +46,7 @@ describe("Header title", () => {
subHeadingType="NetworkSelect"
onPress={jest.fn()}
disabled={false}
/>
/>,
);
expect(rendered.toJSON()).toMatchSnapshot();
});
Expand Down
11 changes: 11 additions & 0 deletions mobile-app/app/contexts/__mocks__/CustomServiceProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const useCustomServiceProviderContext = () => {
return {
evmUrl: "",
ethRpcUrl: "",
isCustomEvmUrl: false,
isCustomEthRpcUrl: false,
defaultEvmUrl: "",
defaultEthRpcUrl: "",
setCustomUrl: jest.fn(),
};
};
6 changes: 6 additions & 0 deletions mobile-app/app/contexts/__mocks__/EVMProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const useEVMProvider = () => {
return {
provider: null,
chainId: 1133,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import { configureStore } from "@reduxjs/toolkit";
import { block } from "@waveshq/walletkit-ui/dist/store/block";
import { loans } from "@store/loans";
import { LoanVaultState } from "@defichain/whale-api-client/dist/api/loan";
import { evm } from "@store/evm";
import { DFIBalanceCard } from "./DFIBalanceCard";

jest.mock("../../../../../contexts/DisplayBalancesContext");
jest.mock("@contexts/DomainContext");
jest.mock("@contexts/EVMProvider");
jest.mock("@contexts/CustomServiceProvider");

jest.mock("@react-navigation/native", () => ({
useNavigation: jest.fn(),
Expand Down Expand Up @@ -110,13 +113,19 @@ describe("DFI Balance Card", () => {
loanSchemes: [],
loanTokens: [],
},
evm: {
evmWalletDetails: null,
evmTokenBalances: [],
hasFetchedEvmTokens: true,
},
};
const store = configureStore({
preloadedState: initialState,
reducer: {
wallet: wallet.reducer,
block: block.reducer,
loans: loans.reducer,
evm: evm.reducer,
},
});
const component = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { wallet } from "@waveshq/walletkit-ui/dist/store";
import { ReceiveScreen } from "./ReceiveScreen";

jest.mock("@shared-contexts/WalletContext");

jest.mock("@contexts/DomainContext");
jest.mock("expo-clipboard", () => ({
setStringAsync: jest.fn(),
}));
Expand Down

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

0 comments on commit feca52c

Please sign in to comment.