PliWould/components/__tests__/ProductEditor-test.tsx
2024-06-28 14:53:48 -07:00

26 lines
1.0 KiB
TypeScript

import { renderWithProviders } from "@/lib/rendering";
import { ProductEditor } from "@/components/ProductEditor";
import {products as fixtures} from "@/__fixtures__/initialProducts";
import { screen } from "@testing-library/react-native";
import { selectProducts } from "@/features/product/productSlice";
describe("ProductEditor", () => {
it("renders correctly", async () => {
const {store} = renderWithProviders(<ProductEditor />, {
products: fixtures,
});
const state1 = store.getState();
const products = selectProducts(state1);
expect(products).toHaveLength(6);
// 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();
});
});