2024-06-28 15:04:50 +02:00
|
|
|
import { renderWithProviders } from "@/lib/rendering";
|
|
|
|
import { ProductEditor } from "@/components/ProductEditor";
|
2024-06-28 23:53:48 +02:00
|
|
|
import {products as fixtures} from "@/__fixtures__/initialProducts";
|
2024-06-28 15:04:50 +02:00
|
|
|
import { screen } from "@testing-library/react-native";
|
2024-06-28 23:53:48 +02:00
|
|
|
import { selectProducts } from "@/features/product/productSlice";
|
2024-06-28 15:04:50 +02:00
|
|
|
|
|
|
|
describe("ProductEditor", () => {
|
|
|
|
it("renders correctly", async () => {
|
|
|
|
const {store} = renderWithProviders(<ProductEditor />, {
|
|
|
|
products: fixtures,
|
|
|
|
});
|
|
|
|
|
2024-06-28 23:53:48 +02:00
|
|
|
const state1 = store.getState();
|
|
|
|
|
|
|
|
const products = selectProducts(state1);
|
|
|
|
|
|
|
|
expect(products).toHaveLength(6);
|
2024-06-28 15:04:50 +02:00
|
|
|
|
|
|
|
// Check if the product names are rendered
|
|
|
|
expect(screen.getByText(products[0].attributes.name as string)).toBeTruthy();
|
|
|
|
expect(screen.getByText(products[1].attributes.name as string)).toBeTruthy();
|
|
|
|
expect(screen.getByText(products[2].attributes.name as string)).toBeTruthy();
|
|
|
|
expect(screen.getByText(products[3].attributes.name as string)).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|