forked from StellarSend/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormField.test.tsx
More file actions
21 lines (21 loc) · 869 Bytes
/
Copy pathFormField.test.tsx
File metadata and controls
21 lines (21 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { render, screen } from "@testing-library/react"
import { describe, it, expect } from "vitest"
import { FormField } from "./FormField"
describe("FormField", () => {
it("renders label", () => {
render(<FormField label="Amount"><input /></FormField>)
expect(screen.getByText("Amount")).toBeInTheDocument()
})
it("shows error message", () => {
render(<FormField label="Amount" error="Required"><input /></FormField>)
expect(screen.getByText("Required")).toBeInTheDocument()
})
it("shows hint when no error", () => {
render(<FormField label="Amount" hint="Min 0.01 XLM"><input /></FormField>)
expect(screen.getByText("Min 0.01 XLM")).toBeInTheDocument()
})
it("renders required asterisk", () => {
render(<FormField label="Amount" required><input /></FormField>)
expect(screen.getByText("*")).toBeInTheDocument()
})
})