Skip to content

Commit

Permalink
feat: ✨ (llm): inte test
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed Dec 12, 2024
1 parent fbddb0b commit 8bd812d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import TestNavigator, { INITIAL_STATE, SlicedMockedAccounts } from "./shared";
import { track } from "~/analytics";

describe("portfolioAssets", () => {
beforeAll(() => {
jest.useFakeTimers();
});
it("should render empty portfolio", async () => {
render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => console.log("modal")} />
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
</TestNavigator>,
{
overrideInitialState: (state: State) => ({
Expand All @@ -26,7 +29,7 @@ describe("portfolioAssets", () => {
it("should render portfolio with assets and accounts list", async () => {
const { user } = render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => console.log("modal")} />
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
</TestNavigator>,
{ ...INITIAL_STATE },
);
Expand All @@ -41,15 +44,17 @@ describe("portfolioAssets", () => {

jest.advanceTimersByTime(600);

//screen.debug();

expect(screen.getByText(/see all accounts/i)).toBeVisible();
expect(screen.getByText(/add new or existing account/i)).toBeVisible();
// await waitFor(() => expect(screen.getByText(/cronos 2/i)).toBeVisible());
// await waitFor(() => expect(screen.getByText(/cronos 2/i)).toBeVisible());
});

it("should hide see all button and display add account button because there is less than 5 assets", async () => {
const { user } = render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => console.log("modal")} />
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
</TestNavigator>,
{
overrideInitialState: (state: State) => ({
Expand Down Expand Up @@ -87,7 +92,7 @@ describe("portfolioAssets", () => {
it("should render assets list screen", async () => {
const { user } = render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => console.log("modal")} />
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
</TestNavigator>,
{ ...INITIAL_STATE },
);
Expand All @@ -107,7 +112,7 @@ describe("portfolioAssets", () => {
it("should render accounts list screen", async () => {
const { user } = render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => console.log("modal")} />
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
</TestNavigator>,
{ ...INITIAL_STATE },
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
import { NavigatorName, ScreenName } from "~/const";
import AssetsListNavigator from "LLM/features/Assets/Navigator";
import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator";
import { MockedAccounts } from "./mockedAccount";
import AccountsListView from "LLM/features/Accounts/components/AccountsListView";
import { State } from "~/reducers/types";
import AccountsNavigator from "LLM/features/Accounts/Navigator";
import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator";
import AssetsList from "LLM/features/Assets/screens/AssetsList";

const Stack = createStackNavigator<BaseNavigatorStackParamList>();
const AccountStack = createStackNavigator();

const AccountNavigator = () => (
<AccountStack.Navigator>
<AccountStack.Screen
name={ScreenName.AccountsList}
component={AccountsListView}
options={{ headerShown: false }}
/>
</AccountStack.Navigator>
);

const TestNavigator = ({ children }: { children: React.ReactNode }) => (
<QueryClientProvider client={new QueryClient()}>
<NavigationContainer independent={true}>
<Stack.Navigator>
<Stack.Screen name={ScreenName.MockedWalletScreen} options={{ headerShown: false }}>
{() => children}
</Stack.Screen>
<Stack.Screen
name={NavigatorName.Assets}
component={AssetsListNavigator}
options={{ headerShown: false }}
/>
<Stack.Screen
name={NavigatorName.Accounts}
component={AccountNavigator}
options={{ headerShown: false }}
/>
</Stack.Navigator>
</NavigationContainer>
<Stack.Navigator initialRouteName={ScreenName.MockedWalletScreen}>
<Stack.Screen name={ScreenName.MockedWalletScreen}>{() => children}</Stack.Screen>
<Stack.Screen
name={ScreenName.AssetsList}
component={AssetsList}
options={{ headerShown: false }}
/>
<Stack.Screen
name={NavigatorName.Accounts}
component={AccountsNavigator}
options={{ headerShown: false }}
/>
</Stack.Navigator>
</QueryClientProvider>
);

Expand Down

0 comments on commit 8bd812d

Please sign in to comment.