fix(forms): separate ngModelGroup from formGroupName
This commit is contained in:
@@ -4,8 +4,7 @@ import {fakeAsync, flushMicrotasks, Log, tick,} from '@angular/core/testing';
|
||||
|
||||
import {SpyNgControl, SpyValueAccessor} from '../spies';
|
||||
|
||||
import {FormGroup, FormControl, FormControlName, NgControlGroup, FormGroupDirective, ControlValueAccessor, Validators, NgForm, NgModel, FormControlDirective, NgControl, DefaultValueAccessor, CheckboxControlValueAccessor, SelectControlValueAccessor, Validator} from '@angular/common/src/forms';
|
||||
|
||||
import {FormGroup, FormControl, FormControlName, FormGroupName, NgModelGroup, FormGroupDirective, ControlValueAccessor, Validators, NgForm, NgModel, FormControlDirective, NgControl, DefaultValueAccessor, CheckboxControlValueAccessor, SelectControlValueAccessor, Validator} from '@angular/common/src/forms';
|
||||
|
||||
import {selectValueAccessor, composeValidators} from '@angular/common/src/forms/directives/shared';
|
||||
import {TimerWrapper} from '../../src/facade/async';
|
||||
@@ -195,7 +194,7 @@ export function main() {
|
||||
};
|
||||
|
||||
it('should set up validator', fakeAsync(() => {
|
||||
var group = new NgControlGroup(
|
||||
var group = new FormGroupName(
|
||||
form, [matchingPasswordsValidator], [asyncValidator('expected')]);
|
||||
group.name = 'passwords';
|
||||
form.addFormGroup(group);
|
||||
@@ -271,7 +270,7 @@ export function main() {
|
||||
form = new NgForm([], []);
|
||||
formModel = form.form;
|
||||
|
||||
personControlGroupDir = new NgControlGroup(form, [], []);
|
||||
personControlGroupDir = new NgModelGroup(form, [], []);
|
||||
personControlGroupDir.name = 'person';
|
||||
|
||||
loginControlDir = new FormControlName(personControlGroupDir, null, null, [defaultAccessor]);
|
||||
@@ -338,7 +337,7 @@ export function main() {
|
||||
}));
|
||||
});
|
||||
|
||||
describe('NgControlGroup', () => {
|
||||
describe('FormGroupName', () => {
|
||||
var formModel: any /** TODO #9100 */;
|
||||
var controlGroupDir: any /** TODO #9100 */;
|
||||
|
||||
@@ -347,7 +346,7 @@ export function main() {
|
||||
|
||||
var parent = new FormGroupDirective([], []);
|
||||
parent.form = new FormGroup({'group': formModel});
|
||||
controlGroupDir = new NgControlGroup(parent, [], []);
|
||||
controlGroupDir = new FormGroupName(parent, [], []);
|
||||
controlGroupDir.name = 'group';
|
||||
});
|
||||
|
||||
|
||||
@@ -991,7 +991,7 @@ export function main() {
|
||||
new FormGroup({'nested': new FormGroup({'login': new FormControl('value')})});
|
||||
|
||||
const t = `<div [formGroup]="form">
|
||||
<div ngControlGroup="nested">
|
||||
<div formGroupName="nested">
|
||||
<input type="text" formControlName="login">
|
||||
</div>
|
||||
</div>`;
|
||||
@@ -1014,7 +1014,7 @@ export function main() {
|
||||
new FormGroup({'nested': new FormGroup({'login': new FormControl('value')})});
|
||||
|
||||
const t = `<div [formGroup]="form">
|
||||
<div ngControlGroup="nested">
|
||||
<div formGroupName="nested">
|
||||
<input type="text" formControlName="login">
|
||||
</div>
|
||||
</div>`;
|
||||
@@ -1083,8 +1083,8 @@ export function main() {
|
||||
it('should add new controls and control groups',
|
||||
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
const t = `<form>
|
||||
<div ngControlGroup="user">
|
||||
<input type="text" formControlName="login">
|
||||
<div ngModelGroup="user">
|
||||
<input type="text" name="login" ngModel>
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
@@ -1137,7 +1137,7 @@ export function main() {
|
||||
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
const t = `<form>
|
||||
<div *ngIf="name == 'show'">
|
||||
<input type="text" formControlName="login">
|
||||
<input type="text" name="login" ngModel>
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
@@ -1161,7 +1161,7 @@ export function main() {
|
||||
it('should remove control groups',
|
||||
fakeAsync(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
const t = `<form>
|
||||
<div *ngIf="name=='show'" ngControlGroup="user">
|
||||
<div *ngIf="name=='show'" ngModelGroup="user">
|
||||
<input type="text" name="login" ngModel>
|
||||
</div>
|
||||
</form>`;
|
||||
@@ -1492,7 +1492,7 @@ export function main() {
|
||||
// {{x.valid}} used to crash because valid() tried to read a property
|
||||
// from form.control before it was set. This test verifies this bug is
|
||||
// fixed.
|
||||
const t = `<form><div ngControlGroup="x" #x="ngForm">
|
||||
const t = `<form><div ngModelGroup="x" #x="ngModelGroup">
|
||||
<input type="text" name="test" ngModel></div>{{x.valid}}</form>`;
|
||||
let fixture = tcb.overrideTemplate(MyComp8, t).createFakeAsync(MyComp8);
|
||||
tick();
|
||||
|
||||
Reference in New Issue
Block a user