From b668768c0a8dc7f070c94f48eedf293165ba2486 Mon Sep 17 00:00:00 2001 From: Krivokhizhin Anton Date: Sun, 22 Nov 2020 00:01:07 +0300 Subject: [PATCH] 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 --- packages/forms/test/form_control_spec.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/forms/test/form_control_spec.ts b/packages/forms/test/form_control_spec.ts index d9eaafdcd4..7caff35c0b 100644 --- a/packages/forms/test/form_control_spec.ts +++ b/packages/forms/test/form_control_spec.ts @@ -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);