Skip to content

Commit 175b7a6

Browse files
committed
test: form group should mark all children dirty
1 parent 5dcab34 commit 175b7a6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libs/reactive-forms/src/lib/form-group.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,20 @@ describe('FormGroup Functionality', () => {
196196
expect(spy).toHaveBeenCalledWith(false);
197197
});
198198

199+
function areAllAllChildrenDirty(control: AbstractControl) {
200+
expect(control.dirty).toBe(true);
201+
(control as any)._forEachChild((control: AbstractControl) => areAllAllChildrenDirty(control));
202+
}
203+
204+
it('should markAllAsDirty', () => {
205+
const control = createGroup();
206+
207+
jest.spyOn(control, 'markAsDirty');
208+
control.markAllAsDirty();
209+
expect(control.markAsDirty).toHaveBeenCalled();
210+
areAllAllChildrenDirty(control);
211+
});
212+
199213
it('should reset', () => {
200214
const control = createGroup();
201215
jest.spyOn(control, 'reset');

0 commit comments

Comments
 (0)