Skip to content
This repository was archived by the owner on Jan 19, 2023. It is now read-only.

Commit b31973c

Browse files
AndrewKushnirthePunderWoman
authored andcommitted
test: remove Ivy/ViewEngine switch helpers and obsolete tests (angular#44120)
This commit removes special functions that were used to run tests in ViewEngine or Ivy only. Since ViewEngine is deprecated and we no longer run ViewEngine tests on CI, we can cleanup those special helpers and ViewEngine-only tests. PR Close angular#44120
1 parent d8e6577 commit b31973c

File tree

59 files changed

+7313
-9708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+7313
-9708
lines changed

packages/bazel/test/ngc-wrapped/flat_module_test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {obsoleteInIvy, onlyInIvy} from '@angular/private/testing';
109
import {runfiles} from '@bazel/runfiles';
1110
import {existsSync, readFileSync} from 'fs';
1211
import {dirname, join} from 'path';
@@ -26,15 +25,8 @@ describe('flat_module ng_module', () => {
2625
});
2726

2827
describe('flat module out file', () => {
29-
obsoleteInIvy('Ngtsc computes the AMD module name differently than NGC')
30-
.it('should have a proper AMD module name', () => {
31-
expect(readFileSync(flatModuleOutFile, 'utf8'))
32-
.toContain(`define("flat_module/flat_module"`);
33-
});
34-
35-
onlyInIvy('Ngtsc computes the AMD module name differently than NGC')
36-
.it('should have a proper AMD module name', () => {
37-
expect(readFileSync(flatModuleOutFile, 'utf8')).toContain(`define("flat_module"`);
38-
});
28+
it('should have a proper AMD module name', () => {
29+
expect(readFileSync(flatModuleOutFile, 'utf8')).toContain(`define("flat_module"`);
30+
});
3931
});
4032
});

packages/compiler-cli/integrationtest/bazel/injector_def/ivy_build/app/test/module_spec.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
*/
88

99
import {forwardRef, Injectable, InjectionToken, Injector, NgModule, ɵcreateInjector as createInjector} from '@angular/core';
10-
import {ivyEnabled} from '@angular/private/testing';
1110
import {AOT_TOKEN, AotModule, AotService} from 'app_built/src/module';
1211

13-
describe('Ivy NgModule', () => {
12+
describe('NgModule', () => {
1413
describe('AOT', () => {
1514
let injector: Injector;
1615

@@ -62,12 +61,11 @@ describe('Ivy NgModule', () => {
6261
class BModule {
6362
}
6463

65-
const errorCode = ivyEnabled ? 'NG0200: ' : '';
66-
const errorLink = ivyEnabled ? '. Find more at https://angular.io/errors/NG0200' : '';
6764
expect(() => createInjector(AModule))
68-
.toThrowError(`${
69-
errorCode}Circular dependency in DI detected for AModule. Dependency path: AModule > BModule > AModule${
70-
errorLink}`);
65+
.toThrowError(
66+
'NG0200: Circular dependency in DI detected for AModule. ' +
67+
'Dependency path: AModule > BModule > AModule. ' +
68+
'Find more at https://angular.io/errors/NG0200');
7169
});
7270

7371
it('merges imports and exports', () => {

packages/core/test/acceptance/bootstrap_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import {ApplicationRef, COMPILER_OPTIONS, Component, destroyPlatform, NgModule, NgZone, TestabilityRegistry, ViewEncapsulation} from '@angular/core';
1010
import {BrowserModule} from '@angular/platform-browser';
1111
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
12-
import {onlyInIvy, withBody} from '@angular/private/testing';
12+
import {withBody} from '@angular/private/testing';
1313

1414
describe('bootstrap', () => {
1515
beforeEach(destroyPlatform);
@@ -242,7 +242,7 @@ describe('bootstrap', () => {
242242
}));
243243
});
244244

245-
onlyInIvy('options cannot be changed in Ivy').describe('changing bootstrap options', () => {
245+
describe('changing bootstrap options', () => {
246246
beforeEach(() => {
247247
spyOn(console, 'error');
248248
});

packages/core/test/acceptance/change_detection_spec.ts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {CommonModule} from '@angular/common';
1111
import {ApplicationRef, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactoryResolver, ComponentRef, Directive, DoCheck, EmbeddedViewRef, ErrorHandler, EventEmitter, Input, NgModule, OnInit, Output, QueryList, TemplateRef, Type, ViewChild, ViewChildren, ViewContainerRef} from '@angular/core';
1212
import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
1313
import {expect} from '@angular/platform-browser/testing/src/matchers';
14-
import {ivyEnabled} from '@angular/private/testing';
1514
import {BehaviorSubject} from 'rxjs';
1615

1716
describe('change detection', () => {
@@ -1122,7 +1121,7 @@ describe('change detection', () => {
11221121
template: ` <ng-container [ngTemplateOutlet]="template"> </ng-container> `
11231122
})
11241123
class Insertion {
1125-
@Input() template !: TemplateRef<{}>;
1124+
@Input() template!: TemplateRef<{}>;
11261125
}
11271126

11281127
// This component uses async pipe (which calls markForCheck) in a view that has different
@@ -1398,34 +1397,29 @@ describe('change detection', () => {
13981397
}
13991398

14001399
it('should include field name in case of property binding', () => {
1401-
const message = ivyEnabled ? `Previous value for 'id': 'initial'. Current value: 'changed'` :
1402-
`Previous value: 'id: initial'. Current value: 'id: changed'`;
1400+
const message = `Previous value for 'id': 'initial'. Current value: 'changed'`;
14031401
expect(() => initWithTemplate('<div [id]="unstableStringExpression"></div>'))
14041402
.toThrowError(new RegExp(message));
14051403
});
14061404

14071405
it('should include field name in case of property interpolation', () => {
1408-
const message = ivyEnabled ?
1409-
`Previous value for 'id': 'Expressions: a and initial!'. Current value: 'Expressions: a and changed!'` :
1410-
`Previous value: 'id: Expressions: a and initial!'. Current value: 'id: Expressions: a and changed!'`;
1406+
const message =
1407+
`Previous value for 'id': 'Expressions: a and initial!'. Current value: 'Expressions: a and changed!'`;
14111408
expect(
14121409
() => initWithTemplate(
14131410
'<div id="Expressions: {{ a }} and {{ unstableStringExpression }}!"></div>'))
14141411
.toThrowError(new RegExp(message));
14151412
});
14161413

14171414
it('should include field name in case of attribute binding', () => {
1418-
const message = ivyEnabled ?
1419-
`Previous value for 'attr.id': 'initial'. Current value: 'changed'` :
1420-
`Previous value: 'id: initial'. Current value: 'id: changed'`;
1415+
const message = `Previous value for 'attr.id': 'initial'. Current value: 'changed'`;
14211416
expect(() => initWithTemplate('<div [attr.id]="unstableStringExpression"></div>'))
14221417
.toThrowError(new RegExp(message));
14231418
});
14241419

14251420
it('should include field name in case of attribute interpolation', () => {
1426-
const message = ivyEnabled ?
1427-
`Previous value for 'attr.id': 'Expressions: a and initial!'. Current value: 'Expressions: a and changed!'` :
1428-
`Previous value: 'id: Expressions: a and initial!'. Current value: 'id: Expressions: a and changed!'`;
1421+
const message =
1422+
`Previous value for 'attr.id': 'Expressions: a and initial!'. Current value: 'Expressions: a and changed!'`;
14291423
expect(
14301424
() => initWithTemplate(
14311425
'<div attr.id="Expressions: {{ a }} and {{ unstableStringExpression }}!"></div>'))
@@ -1450,16 +1444,13 @@ describe('change detection', () => {
14501444
});
14511445

14521446
it('should include style prop name in case of style binding', () => {
1453-
const message = ivyEnabled ? `Previous value for 'color': 'red'. Current value: 'green'` :
1454-
`Previous value: 'color: red'. Current value: 'color: green'`;
1447+
const message = `Previous value for 'color': 'red'. Current value: 'green'`;
14551448
expect(() => initWithTemplate('<div [style.color]="unstableColorExpression"></div>'))
14561449
.toThrowError(new RegExp(message));
14571450
});
14581451

14591452
it('should include class name in case of class binding', () => {
1460-
const message = ivyEnabled ?
1461-
`Previous value for 'someClass': 'true'. Current value: 'false'` :
1462-
`Previous value: 'someClass: true'. Current value: 'someClass: false'`;
1453+
const message = `Previous value for 'someClass': 'true'. Current value: 'false'`;
14631454
expect(() => initWithTemplate('<div [class.someClass]="unstableBooleanExpression"></div>'))
14641455
.toThrowError(new RegExp(message));
14651456
});
@@ -1480,23 +1471,19 @@ describe('change detection', () => {
14801471
});
14811472

14821473
it('should include field name in case of host property binding', () => {
1483-
const message = ivyEnabled ? `Previous value for 'id': 'initial'. Current value: 'changed'` :
1484-
`Previous value: 'id: initial'. Current value: 'id: changed'`;
1474+
const message = `Previous value for 'id': 'initial'. Current value: 'changed'`;
14851475
expect(() => initWithHostBindings({'[id]': 'unstableStringExpression'}))
14861476
.toThrowError(new RegExp(message));
14871477
});
14881478

14891479
it('should include style prop name in case of host style bindings', () => {
1490-
const message = ivyEnabled ? `Previous value for 'color': 'red'. Current value: 'green'` :
1491-
`Previous value: 'color: red'. Current value: 'color: green'`;
1480+
const message = `Previous value for 'color': 'red'. Current value: 'green'`;
14921481
expect(() => initWithHostBindings({'[style.color]': 'unstableColorExpression'}))
14931482
.toThrowError(new RegExp(message));
14941483
});
14951484

14961485
it('should include class name in case of host class bindings', () => {
1497-
const message = ivyEnabled ?
1498-
`Previous value for 'someClass': 'true'. Current value: 'false'` :
1499-
`Previous value: 'someClass: true'. Current value: 'someClass: false'`;
1486+
const message = `Previous value for 'someClass': 'true'. Current value: 'false'`;
15001487
expect(() => initWithHostBindings({'[class.someClass]': 'unstableBooleanExpression'}))
15011488
.toThrowError(new RegExp(message));
15021489
});

packages/core/test/acceptance/change_detection_transplanted_view_spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component, DoCheck, Input, T
1111
import {AfterViewChecked} from '@angular/core/src/core';
1212
import {ComponentFixture, TestBed} from '@angular/core/testing';
1313
import {expect} from '@angular/platform-browser/testing/src/matchers';
14-
import {onlyInIvy} from '@angular/private/testing';
1514

1615
describe('change detection for transplanted views', () => {
1716
describe('when declaration appears before insertion', () => {
@@ -324,7 +323,7 @@ describe('change detection for transplanted views', () => {
324323
changeDetection: ChangeDetectionStrategy.OnPush
325324
})
326325
class Insertion {
327-
@Input() template !: TemplateRef<{}>;
326+
@Input() template!: TemplateRef<{}>;
328327
name = 'initial';
329328
constructor(readonly changeDetectorRef: ChangeDetectorRef) {}
330329
}
@@ -479,7 +478,7 @@ describe('change detection for transplanted views', () => {
479478
template: `<ng-container [ngTemplateOutlet]="template"></ng-container>`
480479
})
481480
class CheckAlwaysInsertion {
482-
@Input() template !: TemplateRef<{}>;
481+
@Input() template!: TemplateRef<{}>;
483482
}
484483

485484
@Component({
@@ -488,7 +487,7 @@ describe('change detection for transplanted views', () => {
488487
changeDetection: ChangeDetectionStrategy.OnPush
489488
})
490489
class OnPushInsertionHost {
491-
@Input() template !: TemplateRef<{}>;
490+
@Input() template!: TemplateRef<{}>;
492491
constructor(readonly cdr: ChangeDetectorRef) {}
493492
}
494493
@Component({
@@ -542,7 +541,7 @@ describe('change detection for transplanted views', () => {
542541
expect(fixture.nativeElement.textContent).toEqual('new');
543542
});
544543

545-
onlyInIvy('behavior is inconsistent in VE').describe('when insertion is detached', () => {
544+
describe('when insertion is detached', () => {
546545
it('does not refresh CheckAlways transplants', () => {
547546
const fixture = getFixture(CheckAlwaysDeclaration);
548547
fixture.detectChanges();
@@ -570,7 +569,7 @@ describe('change detection for transplanted views', () => {
570569
changeDetection: ChangeDetectionStrategy.OnPush
571570
})
572571
class TripleTemplate {
573-
@Input() template !: TemplateRef<{}>;
572+
@Input() template!: TemplateRef<{}>;
574573
}
575574

576575
@Component({

packages/core/test/acceptance/component_spec.ts

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {ApplicationRef, Component, ComponentFactoryResolver, ComponentRef, Eleme
1111
import {TestBed} from '@angular/core/testing';
1212
import {ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';
1313
import {expect} from '@angular/platform-browser/testing/src/matchers';
14-
import {ivyEnabled, onlyInIvy} from '@angular/private/testing';
1514

1615
import {domRendererFactory3} from '../../src/render3/interfaces/renderer';
1716
import {global} from '../../src/util/global';
@@ -388,18 +387,9 @@ describe('component', () => {
388387
}
389388

390389
TestBed.configureTestingModule({declarations: [App, Comp]});
391-
if (ivyEnabled) {
392-
expect(() => TestBed.createComponent(App))
393-
.toThrowError(
394-
/"ng-container" tags cannot be used as component hosts. Please use a different tag to activate the Comp component/);
395-
} else {
396-
// In VE there is no special check for the case when `<ng-container>` is used as a host
397-
// element for a Component. VE tries to attach Component's content to a Comment node that
398-
// represents the `<ng-container>` location and this call fails with a
399-
// browser/environment-specific error message, so we just verify that this scenario is
400-
// triggering an error in VE.
401-
expect(() => TestBed.createComponent(App)).toThrow();
402-
}
390+
expect(() => TestBed.createComponent(App))
391+
.toThrowError(
392+
/"ng-container" tags cannot be used as component hosts. Please use a different tag to activate the Comp component/);
403393
});
404394

405395
it('should throw when <ng-template> is used as a host element for a Component', () => {
@@ -418,15 +408,9 @@ describe('component', () => {
418408
}
419409

420410
TestBed.configureTestingModule({declarations: [App, Comp]});
421-
if (ivyEnabled) {
422-
expect(() => TestBed.createComponent(App))
423-
.toThrowError(
424-
/"ng-template" tags cannot be used as component hosts. Please use a different tag to activate the Comp component/);
425-
} else {
426-
expect(() => TestBed.createComponent(App))
427-
.toThrowError(
428-
/Components on an embedded template: Comp \("\[ERROR ->\]<ng-template><\/ng-template>"\)/);
429-
}
411+
expect(() => TestBed.createComponent(App))
412+
.toThrowError(
413+
/"ng-template" tags cannot be used as component hosts. Please use a different tag to activate the Comp component/);
430414
});
431415
});
432416

@@ -702,9 +686,7 @@ describe('component', () => {
702686
it('with Renderer2',
703687
() => runTestWithRenderer([{provide: RendererFactory2, useClass: DomRendererFactory2}]));
704688

705-
onlyInIvy('Renderer3 is supported only in Ivy')
706-
.it('with Renderer3',
707-
() =>
708-
runTestWithRenderer([{provide: RendererFactory2, useValue: domRendererFactory3}]));
689+
it('with Renderer3',
690+
() => runTestWithRenderer([{provide: RendererFactory2, useValue: domRendererFactory3}]));
709691
});
710692
});

0 commit comments

Comments
 (0)