test(forms): verify that an object is not a boxed value if only `disabled` field is present (#39801)

The value of a `FormControl` is treated in a special way (called boxed values) when it's an object with exactly
2 fields: `value` and `disabled`. This commit adds a test which verifies that an object is not treated as a boxed
value when `disabled` field is present, but `value` is missing.

PR Close #39801
This commit is contained in:
Krivokhizhin Anton 2020-11-22 00:01:07 +03:00 committed by Andrew Kushnir
parent 3e1e5a15ba
commit b668768c0a
1 changed files with 7 additions and 0 deletions

View File

@ -45,6 +45,13 @@ describe('FormControl', () => {
expect(c.status).toBe('DISABLED');
});
it('should not treat objects as boxed values when `disabled` field is present, but `value` is missing',
() => {
const c = new FormControl({disabled: true});
expect(c.value).toEqual({disabled: true});
expect(c.disabled).toBe(false);
});
it('should honor boxed value with disabled control when validating', () => {
const c = new FormControl({value: '', disabled: true}, Validators.required);
expect(c.disabled).toBe(true);