Skip to content

Commit

Permalink
tests products page
Browse files Browse the repository at this point in the history
  • Loading branch information
PS1242 committed Jun 28, 2023
1 parent 1d060b6 commit c7e377d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/products/ProductsPage.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import styles from "./ProductsPage.module.css";
import ProductsList from "./productsList/ProductsList";

Expand Down
23 changes: 23 additions & 0 deletions src/products/ProductsPage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import { screen, render } from "@testing-library/react";
import ProductsPage from "./ProductsPage";
import CartProvider from "../provider/CartProvider";

describe("main products page", () => {
test("products page", () => {
const mockData = {
products: [],
};
jest.spyOn(global, "fetch").mockImplementationOnce(() =>
Promise.resolve({
json: jest.fn().mockResolvedValue(mockData),
})
);
render(
<CartProvider>
<ProductsPage />
</CartProvider>
);
expect(screen.getByText("Products")).toBeInTheDocument();
});
});

0 comments on commit c7e377d

Please sign in to comment.