|
16 | 16 |
|
17 | 17 | import { render, screen } from "@testing-library/angular"; |
18 | 18 | import { Component, signal } from "@angular/core"; |
19 | | - |
20 | | -import { FormMetadataComponent, FormActionComponent, FormSubmitComponent, FormErrorMessageComponent } from "./form"; |
| 19 | +import { injectForm, TanStackAppField } from "@tanstack/angular-form"; |
| 20 | + |
| 21 | +import { |
| 22 | + FormMetadataComponent, |
| 23 | + FormActionComponent, |
| 24 | + FormSubmitComponent, |
| 25 | + FormErrorMessageComponent, |
| 26 | + FormInputComponent, |
| 27 | +} from "./form"; |
21 | 28 | import { ButtonComponent } from "./button"; |
22 | 29 |
|
23 | 30 | @Component({ |
@@ -164,6 +171,35 @@ describe("Form Components", () => { |
164 | 171 | }); |
165 | 172 | }); |
166 | 173 |
|
| 174 | + describe("<fui-form-input>", () => { |
| 175 | + @Component({ |
| 176 | + template: ` |
| 177 | + <fui-form-input name="test" tanstack-app-field [tanstackField]="form" label="Test Label"> |
| 178 | + <button ngProjectAs="input-action" fui-form-action data-testid="test-action">Action</button> |
| 179 | + </fui-form-input> |
| 180 | + `, |
| 181 | + standalone: true, |
| 182 | + imports: [FormInputComponent, TanStackAppField, FormActionComponent], |
| 183 | + }) |
| 184 | + class TestFormInputHostComponent { |
| 185 | + form = injectForm({ |
| 186 | + defaultValues: { |
| 187 | + test: "", |
| 188 | + }, |
| 189 | + }); |
| 190 | + } |
| 191 | + |
| 192 | + it("renders action content when provided", async () => { |
| 193 | + await render(TestFormInputHostComponent, { |
| 194 | + imports: [TestFormInputHostComponent], |
| 195 | + }); |
| 196 | + |
| 197 | + const actionButton = screen.getByTestId("test-action"); |
| 198 | + expect(actionButton).toBeTruthy(); |
| 199 | + expect(actionButton).toHaveTextContent("Action"); |
| 200 | + }); |
| 201 | + }); |
| 202 | + |
167 | 203 | describe("<fui-form-error-message>", () => { |
168 | 204 | it("renders error message when onSubmit error exists", async () => { |
169 | 205 | await render(TestFormErrorMessageHostComponent); |
|
0 commit comments