refactor(forms): remove ngForm element selector (#33058)
Removes the deprecated `ngForm` element selector and all of the code related to it. BREAKING CHANGES: * `<ngForm></ngForm>` can no longer be used as a selector. Use `<ng-form></ng-form>` instead. * The `NgFromSelectorWarning` directive has been removed. * `FormsModule.withConfig` has been removed. Use the `FormsModule` directly. PR Close #33058
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Component, Directive, Type, forwardRef} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing';
|
||||
import {AbstractControl, AsyncValidator, COMPOSITION_BUFFER_MODE, FormControl, FormsModule, NG_ASYNC_VALIDATORS, NgForm, NgFormSelectorWarning, NgModel} from '@angular/forms';
|
||||
import {AbstractControl, AsyncValidator, COMPOSITION_BUFFER_MODE, FormControl, FormsModule, NG_ASYNC_VALIDATORS, NgForm, NgModel} from '@angular/forms';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {dispatchEvent, sortedClassList} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {merge} from 'rxjs';
|
||||
@ -1630,61 +1630,6 @@ import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integrat
|
||||
}));
|
||||
});
|
||||
|
||||
describe('ngForm deprecation warnings', () => {
|
||||
let warnSpy: jasmine.Spy;
|
||||
|
||||
@Component({selector: 'ng-form-deprecated', template: `<ngForm></ngForm><ngForm></ngForm>`})
|
||||
class ngFormDeprecated {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
(NgFormSelectorWarning as any)._ngFormWarning = false;
|
||||
|
||||
warnSpy = spyOn(console, 'warn');
|
||||
});
|
||||
|
||||
describe(`when using the deprecated 'ngForm' selector`, () => {
|
||||
it(`should only warn once when global provider is provided with "once"`, () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ngFormDeprecated],
|
||||
imports: [FormsModule.withConfig({warnOnDeprecatedNgFormSelector: 'once'})]
|
||||
});
|
||||
TestBed.createComponent(ngFormDeprecated);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warnSpy.calls.mostRecent().args[0])
|
||||
.toMatch(/It looks like you're using 'ngForm'/gi);
|
||||
});
|
||||
|
||||
it(`should only warn once by default`, () => {
|
||||
initTest(ngFormDeprecated);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(1);
|
||||
expect(warnSpy.calls.mostRecent().args[0])
|
||||
.toMatch(/It looks like you're using 'ngForm'/gi);
|
||||
});
|
||||
|
||||
it(`should not warn when global provider is provided with "never"`, () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ngFormDeprecated],
|
||||
imports: [FormsModule.withConfig({warnOnDeprecatedNgFormSelector: 'never'})]
|
||||
});
|
||||
TestBed.createComponent(ngFormDeprecated);
|
||||
expect(warnSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it(`should only warn for each instance when global provider is provided with "always"`,
|
||||
() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ngFormDeprecated],
|
||||
imports: [FormsModule.withConfig({warnOnDeprecatedNgFormSelector: 'always'})]
|
||||
});
|
||||
|
||||
TestBed.createComponent(ngFormDeprecated);
|
||||
expect(warnSpy).toHaveBeenCalledTimes(2);
|
||||
expect(warnSpy.calls.mostRecent().args[0])
|
||||
.toMatch(/It looks like you're using 'ngForm'/gi);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user