Skip to content

Commit 1e4ce31

Browse files
kristilwpkozlowski-opensource
authored andcommitted
refactor(core): update tests to use standalone (#61663)
update tests to use standalone components for easier test setup PR Close #61663
1 parent fdcb14d commit 1e4ce31

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/core/test/acceptance/change_detection_spec.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,21 @@ import {
3030
QueryList,
3131
ɵRuntimeError as RuntimeError,
3232
ɵRuntimeErrorCode as RuntimeErrorCode,
33+
signal,
3334
TemplateRef,
3435
Type,
3536
ViewChild,
3637
ViewChildren,
3738
ViewContainerRef,
3839
} from '../../src/core';
39-
import {ComponentFixture, fakeAsync, TestBed, tick} from '../../testing';
40+
import {
41+
ComponentFixture,
42+
ComponentFixtureAutoDetect,
43+
fakeAsync,
44+
TestBed,
45+
tick,
46+
} from '../../testing';
47+
import {By} from '@angular/platform-browser';
4048

4149
describe('change detection', () => {
4250
it('can provide zone and zoneless (last one wins like any other provider) in TestBed', () => {
@@ -51,7 +59,6 @@ describe('change detection', () => {
5159
@Directive({
5260
selector: '[viewManipulation]',
5361
exportAs: 'vm',
54-
standalone: false,
5562
})
5663
class ViewManipulation {
5764
constructor(
@@ -76,12 +83,11 @@ describe('change detection', () => {
7683
template: `
7784
<ng-template #vm="vm" viewManipulation>{{'change-detected'}}</ng-template>
7885
`,
79-
standalone: false,
86+
imports: [ViewManipulation],
8087
})
8188
class TestCmpt {}
8289

8390
it('should detect changes for embedded views inserted through ViewContainerRef', () => {
84-
TestBed.configureTestingModule({declarations: [TestCmpt, ViewManipulation]});
8591
const fixture = TestBed.createComponent(TestCmpt);
8692
const vm = fixture.debugElement.childNodes[0].references['vm'] as ViewManipulation;
8793

@@ -92,7 +98,6 @@ describe('change detection', () => {
9298
});
9399

94100
it('should detect changes for embedded views attached to ApplicationRef', () => {
95-
TestBed.configureTestingModule({declarations: [TestCmpt, ViewManipulation]});
96101
const fixture = TestBed.createComponent(TestCmpt);
97102
const vm = fixture.debugElement.childNodes[0].references['vm'] as ViewManipulation;
98103

@@ -145,15 +150,14 @@ describe('change detection', () => {
145150
<div>{{increment('componentView')}}</div>
146151
<ng-template #vm="vm" viewManipulation>{{increment('embeddedView')}}</ng-template>
147152
`,
148-
standalone: false,
153+
imports: [ViewManipulation],
149154
})
150155
class App {
151156
increment(counter: 'componentView' | 'embeddedView') {
152157
counters[counter]++;
153158
}
154159
}
155160

156-
TestBed.configureTestingModule({declarations: [App, ViewManipulation]});
157161
const fixture = TestBed.createComponent(App);
158162
const vm: ViewManipulation = fixture.debugElement.childNodes[1].references['vm'];
159163
const viewRef = vm.insertIntoVcRef();
@@ -175,7 +179,7 @@ describe('change detection', () => {
175179
@Component({
176180
template: `<ng-template #vm="vm" viewManipulation></ng-template>`,
177181
changeDetection: ChangeDetectionStrategy.OnPush,
178-
standalone: false,
182+
imports: [ViewManipulation],
179183
})
180184
class App {}
181185

@@ -185,7 +189,6 @@ describe('change detection', () => {
185189
<div>{{increment()}}</div>
186190
`,
187191
changeDetection: ChangeDetectionStrategy.OnPush,
188-
standalone: false,
189192
})
190193
class DynamicComp {
191194
increment() {
@@ -194,7 +197,6 @@ describe('change detection', () => {
194197
noop() {}
195198
}
196199

197-
TestBed.configureTestingModule({declarations: [App, ViewManipulation, DynamicComp]});
198200
const fixture = TestBed.createComponent(App);
199201
const vm: ViewManipulation = fixture.debugElement.childNodes[0].references['vm'];
200202
const componentRef = vm.vcRef.createComponent(DynamicComp);

0 commit comments

Comments
 (0)