Skip to content

Commit 345fc90

Browse files
committed
refactor(forms): modernize value accessor integration tests
Migrate the value accessor integration spec to current Angular patterns: - use standalone fixtures that import only the forms module they need, instead of declaring them through an `initTest` helper - replace `*ngFor`/`*ngIf` with `@for`/`@if` - use `inject()` instead of constructor injection The reactive and template integration specs reuse two of these fixtures and are updated to create them directly.
1 parent a36155d commit 345fc90

3 files changed

Lines changed: 194 additions & 175 deletions

File tree

‎packages/forms/test/reactive_integration_spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import {
6666
ValueChangeEvent,
6767
} from '../src/model/abstract_model';
6868

69-
import {MyInput, MyInputForm} from './value_accessor_integration_spec';
69+
import {MyInputForm} from './value_accessor_integration_spec';
7070

7171
// Produces a new @Directive (with a given selector) that represents a validator class.
7272
function createValidatorClass(selector: string) {
@@ -820,7 +820,7 @@ describe('reactive forms integration tests', () => {
820820
});
821821

822822
it('should not add disabled attribute to custom controls when disable() is called', async () => {
823-
const fixture = initTest(MyInputForm, MyInput);
823+
const fixture = TestBed.createComponent(MyInputForm);
824824
const control = new FormControl('some value');
825825
fixture.componentInstance.form = new FormGroup({login: control});
826826
await fixture.whenStable();

‎packages/forms/test/template_integration_spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
Validator,
4242
} from '../index';
4343

44-
import {NgModelCustomComp, NgModelCustomWrapper} from './value_accessor_integration_spec';
44+
import {NgModelCustomWrapper} from './value_accessor_integration_spec';
4545

4646
describe('template-driven forms integration tests', () => {
4747
useAutoTick();
@@ -1383,7 +1383,7 @@ describe('template-driven forms integration tests', () => {
13831383
});
13841384

13851385
it('should disable a custom control if disabled attr is added', async () => {
1386-
const fixture = initTest(NgModelCustomWrapper, NgModelCustomComp);
1386+
const fixture = TestBed.createComponent(NgModelCustomWrapper);
13871387
fixture.componentInstance.name = 'Nancy';
13881388
fixture.componentInstance.isDisabled = true;
13891389
await fixture.whenStable();

0 commit comments

Comments
 (0)