-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting
More file actions
26 lines (22 loc) · 666 Bytes
/
Copy pathTesting
File metadata and controls
26 lines (22 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { render, screen, fireEvent } from "@testing-library/react";
import { FormGenerator } from "./components/FormGenerator";
// Sample schema for testing
const sampleSchema = {
formTitle: "Test Form",
formDescription: "This is a test form",
fields: [
{
id: "email",
type: "email",
label: "Email",
required: true,
},
],
};
test("Form validation works correctly", () => {
render(<FormGenerator schema={sampleSchema} />);
const submitButton = screen.getByText("Submit");
fireEvent.click(submitButton);
// Check for validation error
expect(screen.getByText("This field is required")).toBeInTheDocument();
});