test(forms): field directive marks field as touched on 'blur' events (#64485)

This was implemented but missing a test case.

PR Close #64485
This commit is contained in:
Leon Senft
2025-10-16 16:58:31 -07:00
committed by Jessica Janiuk
parent ecb2507c8b
commit e9740662c3
2 changed files with 22 additions and 1 deletions
@@ -994,6 +994,28 @@ describe('field directive', () => {
]);
});
it(`should mark field as touched on native control 'blur' event`, () => {
@Component({
imports: [Field],
template: `<input [field]="f">`,
})
class TestCmp {
f = form(signal(''));
}
const fixture = act(() => TestBed.createComponent(TestCmp));
const input = fixture.nativeElement.firstChild as HTMLInputElement;
const field = fixture.componentInstance.f;
expect(field().touched()).toBe(false);
act(() => {
input.dispatchEvent(new Event('blur'));
});
expect(field().touched()).toBe(true);
});
it('should synchronize with custom control touched status', () => {
@Component({
selector: 'my-input',