feat(forms): allow markAsPending to emit events (#20212)
closes #17958 BREAKING CHANGE: - `AbstractControl#statusChanges` now emits an event of `'PENDING'` when you call `AbstractControl#markAsPending` - Previously it did not emit an event when you called `markAsPending` - To migrate you would need to ensure that if you are filtering or checking events from `statusChanges` that you account for the new event when calling `markAsPending` PR Close #20212
This commit is contained in:

committed by
Victor Berchet

parent
90e9c59e23
commit
e86b64b620
@ -1161,5 +1161,37 @@ import {FormArray} from '@angular/forms/src/model';
|
||||
|
||||
});
|
||||
});
|
||||
describe('pending', () => {
|
||||
let c: FormControl;
|
||||
|
||||
beforeEach(() => { c = new FormControl('value'); });
|
||||
|
||||
it('should be false after creating a control', () => { expect(c.pending).toEqual(false); });
|
||||
|
||||
it('should be true after changing the value of the control', () => {
|
||||
c.markAsPending();
|
||||
expect(c.pending).toEqual(true);
|
||||
});
|
||||
|
||||
describe('status change events', () => {
|
||||
let logger: string[];
|
||||
|
||||
beforeEach(() => {
|
||||
logger = [];
|
||||
c.statusChanges.subscribe((status) => logger.push(status));
|
||||
});
|
||||
|
||||
it('should emit event after marking control as pending', () => {
|
||||
c.markAsPending();
|
||||
expect(logger).toEqual(['PENDING']);
|
||||
});
|
||||
|
||||
it('should not emit event when emitEvent = false', () => {
|
||||
c.markAsPending({emitEvent: false});
|
||||
expect(logger).toEqual([]);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
Reference in New Issue
Block a user