diff --git a/packages/core/src/AutoForm.test.tsx b/packages/core/src/AutoForm.test.tsx index 39bebc9..63757ab 100644 --- a/packages/core/src/AutoForm.test.tsx +++ b/packages/core/src/AutoForm.test.tsx @@ -1,19 +1,29 @@ -import { describe, it, vi, expect } from 'vitest'; -import { fireEvent, render, prettyDOM } from '@testing-library/react'; -import { createAutoForm } from './AutoForm'; -import { useForm } from 'react-hook-form'; -import protobuf from 'protobufjs'; -import React from 'react'; +import { describe, it, vi, expect, afterEach } from "vitest"; +import { + fireEvent, + render, + prettyDOM, + cleanup, + waitFor, +} from "@testing-library/react"; +import { createAutoForm } from "./AutoForm"; +import { useForm } from "react-hook-form"; +import protobuf from "protobufjs"; +import React from "react"; const namespace = protobuf.parse(` syntax = "proto3"; -message Child { +message GrandChild { map items = 1; } +message Child { + GrandChild gc = 1; +} + message Parent { - repeated Child children = 1; + repeated string children = 1; } `).root; @@ -21,21 +31,51 @@ const MockApp: React.FC<{ onSubmit: (values: unknown) => void }> = (props) => { const form = useForm(); const { AutoForm } = createAutoForm({ form, - messageType: 'Parent', + messageType: "Parent", namespace, - }) + }); - return -} + return ( + + + + ); +}; -describe('AutoForm', () => { - it('Form submission', async () => { +afterEach(cleanup); + +describe("AutoForm", () => { + it("Form submission", async () => { const handleSubmit = vi.fn(); - const dom = render( diff --git a/packages/core/src/common/DelButton.tsx b/packages/core/src/common/DelButton.tsx index 680eaf9..3b7e24c 100644 --- a/packages/core/src/common/DelButton.tsx +++ b/packages/core/src/common/DelButton.tsx @@ -6,7 +6,7 @@ interface Props { } const AddButton: React.FC = ({ onClick }) => ( - );