import { Product } from "@/lib/product" import {ProductAttributeEditor} from "../ProductAttributeEditor" import { area } from "enheter" import { fireEvent, render, screen } from '@testing-library/react-native'; import React from "react"; import { emitTypingEvents } from "@testing-library/react-native/build/user-event/type/type"; describe("Product editor tests", () => { const productName = "Fun Product"; it("Product attributes can be deleted", async () => { const product = new Product( 100, {l: 100, u: "foot"}, {"name" : productName} ); const onChange = jest.fn(); const onDelete = jest.fn(); render( ); expect(screen.getByLabelText("Delete Attribute")).not.toBeNull(); fireEvent.press(await screen.getByLabelText("Delete Attribute")); expect(onDelete).toHaveBeenCalled(); }); it("Product attributes can be modified", async () => { const product = new Product( 100, {l: 100, u: "foot"}, {"name" : productName} ); const onChange = jest.fn(); const onDelete = jest.fn(); const onKeyChange = jest.fn(); render( ); fireEvent.changeText(screen.getByLabelText("Edit Key"), "new test key"); expect(onKeyChange).toHaveBeenCalled(); fireEvent.changeText(screen.getByLabelText("Edit Value"), "new name"); expect(onChange).toHaveBeenCalled(); fireEvent.press(screen.getByLabelText("Delete Attribute")); expect(onDelete).toHaveBeenCalled(); }) })