move away from ehemer to resolve recursive loop.
This commit is contained in:
@ -3,7 +3,6 @@ import { deleteProduct, selectProducts, updateProduct } from "@/features/product
|
||||
import { Product } from "@/lib/product";
|
||||
import { FlatList, SafeAreaView, StyleSheet, Text } from "react-native";
|
||||
import { ProductEditorItem } from "./ProductEditorItem";
|
||||
import React from "react";
|
||||
|
||||
export const ProductEditor = ({}) => {
|
||||
const products = useAppSelector(selectProducts) as Product [];
|
||||
|
@ -28,7 +28,7 @@ export function ProductTile ({product, onProductSelected, style} : ProductTilePr
|
||||
style={styles.image}
|
||||
>
|
||||
<Text style={styles.text}>{product.attributes.name || `Product ${product.id}`}</Text>
|
||||
<Text style={styles.text}>{ product.pricePerUnit.toString() } / {product.measurement.value} {product.measurement.unit.symbol} </Text>
|
||||
<Text style={styles.text}>{ product.pricePerUnit.toString() } / {product.measure.value} {product.measure.unit.symbol} </Text>
|
||||
</ImageBackground>
|
||||
</View>
|
||||
);
|
||||
|
@ -1,10 +1,8 @@
|
||||
import { renderWithProviders } from "@/lib/rendering";
|
||||
import { ProductEditor } from "@/components/ProductEditor";
|
||||
import {products as fixtures} from "../../__fixtures__/initialProducts";
|
||||
import React from "react";
|
||||
import { useAppSelector } from "@/app/store";
|
||||
import { selectProducts } from "@/features/product/productSlice";
|
||||
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 () => {
|
||||
@ -12,7 +10,11 @@ describe("ProductEditor", () => {
|
||||
products: fixtures,
|
||||
});
|
||||
|
||||
const products = store.getState();
|
||||
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();
|
||||
|
Reference in New Issue
Block a user