Skip to content

Commit

Permalink
test: explorer - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hussedev committed Sep 26, 2024
1 parent 4429e17 commit 4ee5302
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { CartProject } from "@/features/api/types";
import { useCartStorage } from "@/store";
import { useEffect } from "react";
import tw from "tailwind-styled-components";

export default function NavbarCart() {
export default function NavbarCartContainer() {
/** This part keeps the store in sync between tabs */
const store = useCartStorage();

const projects = store.projects;

const projectCount = projects.length;

const updateStore = () => {
useCartStorage.persist.rehydrate();
};
Expand All @@ -24,6 +23,12 @@ export default function NavbarCart() {
}, []);
/** end of part that keeps the store in sync between tabs */

return <NavbarCart cart={projects} />;
}

export function NavbarCart({ cart }: { cart: CartProject[] }) {
const projectCount = cart.length;

return (
<div
data-testid="navbar-cart"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, fireEvent, screen } from "@testing-library/react";
import NavbarCart from "../Navbar/NavbarCart";
import { NavbarCart } from "../Navbar/NavbarCart";
import { makeApprovedProjectData } from "../../../test-utils";
import { beforeEach } from "vitest"; // replace with the correct path to your NavbarCart component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ vi.mock("wagmi", async () => {
});

describe("LandingPage", () => {

it("renders landing page", () => {
renderWithContext(<LandingPage />);
});
Expand All @@ -83,13 +82,16 @@ describe("LandingPage", () => {

renderWithContext(<LandingPage />, { dataLayer: mockDataLayer });

await waitFor(() => {
// Check if the fetched active rounds are displayed
mockedRounds.forEach((round) => {
expect(
screen.getByText(round.roundMetadata?.name ?? "")
).toBeInTheDocument();
});
});
await waitFor(
() => {
// Check if the fetched active rounds are displayed
mockedRounds.forEach((round) => {
expect(
screen.getByText(round.roundMetadata?.name ?? "")
).toBeInTheDocument();
});
},
{ timeout: 5000 }
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ describe("useFilterRounds", () => {
}
);

await waitFor(() =>
expect(result?.current.data?.length).toBe(
mockedRoundsOverAllChains.length
)
await waitFor(
() => {
console.log("Result data:", result?.current.data); // Debugging statement
expect(result?.current.data?.length).toBe(
mockedRoundsOverAllChains.length
);
},
{ timeout: 5000 } // Wait for up to 5 seconds
);
});

Expand Down

0 comments on commit 4ee5302

Please sign in to comment.