diff --git a/packages/forms/test/reactive_integration_spec.ts b/packages/forms/test/reactive_integration_spec.ts
index 1dfd3c63d3..3e758b0aed 100644
--- a/packages/forms/test/reactive_integration_spec.ts
+++ b/packages/forms/test/reactive_integration_spec.ts
@@ -6,14 +6,15 @@
* found in the LICENSE file at https://angular.io/license
*/
-import {Component, Directive, EventEmitter, Input, Output, Type, forwardRef} from '@angular/core';
+import {Component, Directive, Input, Type, forwardRef} from '@angular/core';
import {ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/testing';
-import {AbstractControl, AsyncValidator, AsyncValidatorFn, COMPOSITION_BUFFER_MODE, ControlValueAccessor, FormArray, FormControl, FormGroup, FormGroupDirective, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl, ReactiveFormsModule, Validators} from '@angular/forms';
+import {AbstractControl, AsyncValidator, AsyncValidatorFn, COMPOSITION_BUFFER_MODE, FormArray, FormControl, FormGroup, FormGroupDirective, FormsModule, NG_ASYNC_VALIDATORS, NG_VALIDATORS, ReactiveFormsModule, Validators} from '@angular/forms';
import {By} from '@angular/platform-browser/src/dom/debug/by';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util';
import {timer} from 'rxjs/observable/timer';
import {_do} from 'rxjs/operator/do';
+import {MyInput, MyInputForm} from './value_accessor_integration_spec';
export function main() {
describe('reactive forms integration tests', () => {
@@ -75,7 +76,7 @@ export function main() {
});
- describe('rebound form groups', () => {
+ describe('re-bound form groups', () => {
it('should update DOM elements initially', () => {
const fixture = initTest(FormGroupComp);
@@ -110,24 +111,6 @@ export function main() {
expect(input.nativeElement.value).toEqual('Carson');
});
- it('should work with radio buttons when reusing control', () => {
- const fixture = initTest(FormControlRadioButtons);
- const food = new FormControl('chicken');
- fixture.componentInstance.form =
- new FormGroup({'food': food, 'drink': new FormControl('')});
- fixture.detectChanges();
-
- const newForm = new FormGroup({'food': food, 'drink': new FormControl('')});
- fixture.componentInstance.form = newForm;
- fixture.detectChanges();
-
- newForm.setValue({food: 'fish', drink: ''});
- fixture.detectChanges();
- const inputs = fixture.debugElement.queryAll(By.css('input'));
- expect(inputs[0].nativeElement.checked).toBe(false);
- expect(inputs[1].nativeElement.checked).toBe(true);
- });
-
it('should update nested form group model when UI changes', () => {
const fixture = initTest(NestedFormGroupComp);
fixture.componentInstance.form = new FormGroup(
@@ -340,95 +323,6 @@ export function main() {
});
- describe('select controls', () => {
- it(`should support primitive values`, () => {
- const fixture = initTest(FormControlNameSelect);
- fixture.detectChanges();
-
- // model -> view
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual('SF');
- expect(sfOption.nativeElement.selected).toBe(true);
-
- select.nativeElement.value = 'NY';
- dispatchEvent(select.nativeElement, 'change');
- fixture.detectChanges();
-
- // view -> model
- expect(sfOption.nativeElement.selected).toBe(false);
- expect(fixture.componentInstance.form.value).toEqual({'city': 'NY'});
- });
-
- it(`should support objects`, () => {
- const fixture = initTest(FormControlSelectNgValue);
- fixture.detectChanges();
-
- // model -> view
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual('0: Object');
- expect(sfOption.nativeElement.selected).toBe(true);
- });
-
- it('should throw an error if compareWith is not a function', () => {
- const fixture = initTest(FormControlSelectWithCompareFn);
- fixture.componentInstance.compareFn = null !;
- expect(() => fixture.detectChanges())
- .toThrowError(/compareWith must be a function, but received null/);
- });
-
- it('should compare options using provided compareWith function', () => {
- const fixture = initTest(FormControlSelectWithCompareFn);
- fixture.detectChanges();
-
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual('0: Object');
- expect(sfOption.nativeElement.selected).toBe(true);
- });
- });
-
- describe('select multiple controls', () => {
- it('should support primitive values', () => {
- const fixture = initTest(FormControlSelectMultiple);
- fixture.detectChanges();
-
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual(`0: 'SF'`);
- expect(sfOption.nativeElement.selected).toBe(true);
- });
-
- it('should support objects', () => {
- const fixture = initTest(FormControlSelectMultipleNgValue);
- fixture.detectChanges();
-
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual('0: Object');
- expect(sfOption.nativeElement.selected).toBe(true);
- });
-
- it('should throw an error when compareWith is not a function', () => {
- const fixture = initTest(FormControlSelectMultipleWithCompareFn);
- fixture.componentInstance.compareFn = null !;
- expect(() => fixture.detectChanges())
- .toThrowError(/compareWith must be a function, but received null/);
- });
-
- it('should compare options using provided compareWith function', fakeAsync(() => {
- const fixture = initTest(FormControlSelectMultipleWithCompareFn);
- fixture.detectChanges();
- tick();
-
- const select = fixture.debugElement.query(By.css('select'));
- const sfOption = fixture.debugElement.query(By.css('option'));
- expect(select.nativeElement.value).toEqual('0: Object');
- expect(sfOption.nativeElement.selected).toBe(true);
- }));
- });
-
describe('form arrays', () => {
it('should support form arrays', () => {
const fixture = initTest(FormArrayComp);
@@ -837,482 +731,6 @@ export function main() {
});
- describe('value accessors', () => {
-
- it('should support without type', () => {
- TestBed.overrideComponent(
- FormControlComp, {set: {template: ``}});
- const fixture = initTest(FormControlComp);
- const control = new FormControl('old');
- fixture.componentInstance.control = control;
- fixture.detectChanges();
-
- // model -> view
- const input = fixture.debugElement.query(By.css('input'));
- expect(input.nativeElement.value).toEqual('old');
-
- input.nativeElement.value = 'new';
- dispatchEvent(input.nativeElement, 'input');
-
- // view -> model
- expect(control.value).toEqual('new');
- });
-
- it('should support ', () => {
- const fixture = initTest(FormGroupComp);
- const form = new FormGroup({'login': new FormControl('old')});
- fixture.componentInstance.form = form;
- fixture.detectChanges();
-
- // model -> view
- const input = fixture.debugElement.query(By.css('input'));
- expect(input.nativeElement.value).toEqual('old');
-
- input.nativeElement.value = 'new';
- dispatchEvent(input.nativeElement, 'input');
-
- // view -> model
- expect(form.value).toEqual({'login': 'new'});
- });
-
- it('should ignore the change event for ', () => {
- const fixture = initTest(FormGroupComp);
- const form = new FormGroup({'login': new FormControl('oldValue')});
- fixture.componentInstance.form = form;
- fixture.detectChanges();
-
- const input = fixture.debugElement.query(By.css('input'));
- form.valueChanges.subscribe({next: (value) => { throw 'Should not happen'; }});
- input.nativeElement.value = 'updatedValue';
-
- dispatchEvent(input.nativeElement, 'change');
- });
-
- it('should support