fix(forms): getRawValue should correctly work with nested FormGroups/Arrays (#12964)

Closed #12963

PR Close #12964
This commit is contained in:
Dzmitry Shylovich
2016-11-18 14:44:05 +03:00
committed by Miško Hevery
parent 7ac38aa357
commit 1ece7366c8
3 changed files with 41 additions and 3 deletions

View File

@ -32,6 +32,7 @@ export function main() {
}
describe('FormArray', () => {
describe('adding/removing', () => {
let a: FormArray;
let c1: FormControl, c2: FormControl, c3: FormControl;
@ -81,6 +82,21 @@ export function main() {
});
});
describe('getRawValue()', () => {
let a: FormArray;
it('should work with nested form groups/arrays', () => {
a = new FormArray([
new FormGroup({'c2': new FormControl('v2'), 'c3': new FormControl('v3')}),
new FormArray([new FormControl('v4'), new FormControl('v5')])
]);
a.at(0).get('c3').disable();
(a.at(1) as FormArray).at(1).disable();
expect(a.getRawValue()).toEqual([{'c2': 'v2', 'c3': 'v3'}, ['v4', 'v5']]);
});
});
describe('setValue', () => {
let c: FormControl, c2: FormControl, a: FormArray;