Skip to content

Commit c0601db

Browse files
JeanMecheatscott
authored andcommitted
test(core): remove some ViewEngine related test code (#48238)
Some tests had comments relating to ViewEngine that were not needed anymore since VE was dropped. PR Close #48238
1 parent aa920aa commit c0601db

File tree

3 files changed

+58
-67
lines changed

3 files changed

+58
-67
lines changed

packages/core/test/acceptance/content_spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,7 @@ describe('projection', () => {
995995
const fixture = TestBed.createComponent(CardWithTitle);
996996
fixture.detectChanges();
997997

998-
// Compare the text output, because Ivy and ViewEngine produce slightly different HTML.
999-
expect(fixture.nativeElement.textContent)
1000-
.toContain('Title --- Subtitle --- content --- footer');
998+
expect(fixture.nativeElement.textContent).toEqual('Title --- Subtitle --- content --- footer');
1001999
});
10021000

10031001
it('should support ngProjectAs on elements (including <ng-content>)', () => {
@@ -1037,8 +1035,7 @@ describe('projection', () => {
10371035
const fixture = TestBed.createComponent(App);
10381036
fixture.detectChanges();
10391037

1040-
// Compare the text output, because Ivy and ViewEngine produce slightly different HTML.
1041-
expect(fixture.nativeElement.textContent).toContain('Title --- content');
1038+
expect(fixture.nativeElement.textContent).toEqual('Title --- content');
10421039
});
10431040

10441041
it('should not match multiple selectors in ngProjectAs', () => {
@@ -1066,8 +1063,7 @@ describe('projection', () => {
10661063
const fixture = TestBed.createComponent(App);
10671064
fixture.detectChanges();
10681065

1069-
// Compare the text output, because Ivy and ViewEngine produce slightly different HTML.
1070-
expect(fixture.nativeElement.textContent).not.toContain('Title content');
1066+
expect(fixture.nativeElement.textContent).not.toEqual('Title content');
10711067
});
10721068

10731069
it('should preserve ngProjectAs and other attributes on projected element', () => {

packages/core/test/acceptance/integration_spec.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,9 +1119,7 @@ describe('acceptance integration tests', () => {
11191119

11201120
const styles = fixture.componentInstance.mockStyleDirective.stylesVal;
11211121

1122-
// Use `toContain` since Ivy and ViewEngine have some slight differences in formatting.
1123-
expect(styles).toContain('width: 100px');
1124-
expect(styles).toContain('height: 200px');
1122+
expect(styles).toEqual('width: 100px; height: 200px;');
11251123
});
11261124

11271125
it('should update `[class]` and bindings in the provided directive if the input is matched',
@@ -1458,8 +1456,7 @@ describe('acceptance integration tests', () => {
14581456
.createComponent(SomeComponent);
14591457
})
14601458
.toThrowError(
1461-
// The ViewEngine error has a typo, whereas the Ivy one fixes it.
1462-
/^Unexpected directive 'SomeComponent' imported by the module 'ModuleWithImportedComponent'\. Please add (a|an) @NgModule annotation\.$/);
1459+
/^Unexpected directive 'SomeComponent' imported by the module 'ModuleWithImportedComponent'\. Please add an @NgModule annotation\.$/);
14631460
});
14641461

14651462
it('should throw with descriptive error message when a pipe is passed to imports', () => {
@@ -1477,8 +1474,7 @@ describe('acceptance integration tests', () => {
14771474
.createComponent(FixtureComponent);
14781475
})
14791476
.toThrowError(
1480-
// The ViewEngine error has a typo, whereas the Ivy one fixes it.
1481-
/^Unexpected pipe 'SomePipe' imported by the module 'ModuleWithImportedPipe'\. Please add (a|an) @NgModule annotation\.$/);
1477+
/^Unexpected pipe 'SomePipe' imported by the module 'ModuleWithImportedPipe'\. Please add an @NgModule annotation\.$/);
14821478
});
14831479

14841480
it('should throw with descriptive error message when a module is passed to declarations', () => {
@@ -1530,8 +1526,7 @@ describe('acceptance integration tests', () => {
15301526
.createComponent(FixtureComponent);
15311527
})
15321528
.toThrowError(
1533-
// The ViewEngine error has a typo, whereas the Ivy one fixes it.
1534-
/^Unexpected value 'SomeModule' imported by the module 'ModuleWithImportedModule'\. Please add (a|an) @NgModule annotation\.$/);
1529+
/^Unexpected value 'SomeModule' imported by the module 'ModuleWithImportedModule'\. Please add an @NgModule annotation\.$/);
15351530
});
15361531
});
15371532

packages/core/test/acceptance/ng_module_spec.ts

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

99
import {CommonModule} from '@angular/common';
10-
import {Component, createNgModule, CUSTOM_ELEMENTS_SCHEMA, destroyPlatform, Directive, Injectable, InjectionToken, NgModule, NgModuleRef, NO_ERRORS_SCHEMA, Pipe, ɵsetClassMetadata as setClassMetadata, ɵɵdefineComponent as defineComponent, ɵɵdefineInjector as defineInjector, ɵɵdefineNgModule as defineNgModule, ɵɵelement as element, ɵɵproperty as property} from '@angular/core';
10+
import {Component, createNgModule, CUSTOM_ELEMENTS_SCHEMA, destroyPlatform, Directive, Injectable, InjectionToken, NgModule, NgModuleRef, NO_ERRORS_SCHEMA, Pipe, ɵsetClassMetadata as setClassMetadata, ɵɵdefineComponent as defineComponent, ɵɵdefineInjector as defineInjector, ɵɵdefineNgModule as defineNgModule, ɵɵelement as element, ɵɵproperty as property,} from '@angular/core';
1111
import {KNOWN_CONTROL_FLOW_DIRECTIVES} from '@angular/core/src/render3/instructions/element_validation';
1212
import {TestBed} from '@angular/core/testing';
1313
import {BrowserModule} from '@angular/platform-browser';
@@ -249,10 +249,10 @@ describe('NgModule', () => {
249249
@Component({
250250
selector: 'my-comp',
251251
template: `
252-
<ng-container *ngIf="condition">
253-
<div [unknown-prop]="true"></div>
254-
</ng-container>
255-
`,
252+
<ng-container *ngIf="condition">
253+
<div [unknown-prop]="true"></div>
254+
</ng-container>
255+
`,
256256
})
257257
class MyComp {
258258
condition = true;
@@ -278,9 +278,7 @@ describe('NgModule', () => {
278278
it('should log an error on unknown props of `ng-template` if NO_ERRORS_SCHEMA is absent', () => {
279279
@Component({
280280
selector: 'my-comp',
281-
template: `
282-
<ng-template *ngIf="condition"></ng-template>
283-
`,
281+
template: ` <ng-template *ngIf="condition"></ng-template> `,
284282
})
285283
class MyComp {
286284
condition = true;
@@ -306,9 +304,7 @@ describe('NgModule', () => {
306304
it('should log an error on unknown props of `ng-container` if NO_ERRORS_SCHEMA is absent', () => {
307305
@Component({
308306
selector: 'my-comp',
309-
template: `
310-
<ng-container *ngIf="condition"></ng-container>
311-
`,
307+
template: ` <ng-container *ngIf="condition"></ng-container> `,
312308
})
313309
class MyComp {
314310
condition = true;
@@ -334,9 +330,7 @@ describe('NgModule', () => {
334330
it('should log an error on unknown props of `ng-content` if NO_ERRORS_SCHEMA is absent', () => {
335331
@Component({
336332
selector: 'my-comp',
337-
template: `
338-
<ng-content *ngIf="condition"></ng-content>
339-
`,
333+
template: ` <ng-content *ngIf="condition"></ng-content> `,
340334
})
341335
class MyComp {
342336
condition = true;
@@ -364,10 +358,10 @@ describe('NgModule', () => {
364358
@Component({
365359
selector: 'my-comp',
366360
template: `
367-
<ng-container *ngIf="condition">
368-
<div [unknown-prop]="true"></div>
369-
</ng-container>
370-
`,
361+
<ng-container *ngIf="condition">
362+
<div [unknown-prop]="true"></div>
363+
</ng-container>
364+
`,
371365
})
372366
class MyComp {
373367
condition = true;
@@ -483,7 +477,7 @@ describe('NgModule', () => {
483477
@Component({
484478
template: `<custom-el></custom-el>`,
485479
standalone: true,
486-
schemas: [CUSTOM_ELEMENTS_SCHEMA]
480+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
487481
})
488482
class MyComp {
489483
}
@@ -629,9 +623,9 @@ describe('NgModule', () => {
629623
`NG0303: Can't bind to 'unknownProp' since it isn't a known property of 'may-be-web-component' \\(used in the 'MyComp' component template\\).`,
630624
`1. If 'may-be-web-component' is an Angular component and it has the 'unknownProp' input, then verify that it is a part of an @NgModule where this component is declared.`,
631625
`2. If 'may-be-web-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.`,
632-
`3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.`
626+
`3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.`,
633627
];
634-
lines.forEach(line => expect(errorMessage).toMatch(line));
628+
lines.forEach((line) => expect(errorMessage).toMatch(line));
635629
});
636630

637631
KNOWN_CONTROL_FLOW_DIRECTIVES.forEach((correspondingImport, directive) => {
@@ -664,9 +658,9 @@ describe('NgModule', () => {
664658
directive}' since it isn't a known property of 'div' \\(used in the 'App' component template\\).`,
665659
`If the '${directive}' is an Angular control flow directive, please make sure ` +
666660
`that either the '${
667-
correspondingImport}' directive or the 'CommonModule' is a part of an @NgModule where this component is declared.`
661+
correspondingImport}' directive or the 'CommonModule' is a part of an @NgModule where this component is declared.`,
668662
];
669-
lines.forEach(line => expect(errorMessage).toMatch(line));
663+
lines.forEach((line) => expect(errorMessage).toMatch(line));
670664
});
671665

672666
it(`should produce a warning when the '${directive}' directive ` +
@@ -692,9 +686,9 @@ describe('NgModule', () => {
692686
directive}' since it isn't a known property of 'div' \\(used in the 'App' component template\\).`,
693687
`If the '${directive}' is an Angular control flow directive, please make sure ` +
694688
`that either the '${
695-
correspondingImport}' directive or the 'CommonModule' is included in the '@Component.imports' of this component.`
689+
correspondingImport}' directive or the 'CommonModule' is included in the '@Component.imports' of this component.`,
696690
];
697-
lines.forEach(line => expect(errorMessage).toMatch(line));
691+
lines.forEach((line) => expect(errorMessage).toMatch(line));
698692
});
699693
});
700694

@@ -710,16 +704,17 @@ describe('NgModule', () => {
710704
vars,
711705
consts,
712706
template,
713-
encapsulation: 2
707+
encapsulation: 2,
714708
});
715709
}
716710
setClassMetadata(
717-
Comp, [{
718-
type: Component,
719-
args: [
720-
{selector: 'comp', template: '...'},
721-
]
722-
}],
711+
Comp,
712+
[
713+
{
714+
type: Component,
715+
args: [{selector: 'comp', template: '...'}],
716+
},
717+
],
723718
null, null);
724719
return Comp;
725720
}
@@ -730,13 +725,18 @@ describe('NgModule', () => {
730725
static ɵinj = defineInjector({});
731726
}
732727
setClassMetadata(
733-
Module, [{
734-
type: NgModule,
735-
args: [{
736-
declarations: [Comp],
737-
schemas: [NO_ERRORS_SCHEMA],
738-
}]
739-
}],
728+
Module,
729+
[
730+
{
731+
type: NgModule,
732+
args: [
733+
{
734+
declarations: [Comp],
735+
schemas: [NO_ERRORS_SCHEMA],
736+
},
737+
],
738+
},
739+
],
740740
null, null);
741741
return Module;
742742
}
@@ -839,7 +839,7 @@ describe('NgModule', () => {
839839
TestBed.configureTestingModule({
840840
declarations: [MyComp],
841841
schemas: [CUSTOM_ELEMENTS_SCHEMA],
842-
errorOnUnknownElements: true
842+
errorOnUnknownElements: true,
843843
});
844844

845845
const fixture = TestBed.createComponent(MyComp);
@@ -871,8 +871,11 @@ describe('NgModule', () => {
871871
}
872872

873873
const spy = spyOn(console, 'error');
874-
TestBed.configureTestingModule(
875-
{declarations: [MyComp], schemas: [NO_ERRORS_SCHEMA], errorOnUnknownElements: true});
874+
TestBed.configureTestingModule({
875+
declarations: [MyComp],
876+
schemas: [NO_ERRORS_SCHEMA],
877+
errorOnUnknownElements: true,
878+
});
876879

877880
const fixture = TestBed.createComponent(MyComp);
878881
fixture.detectChanges();
@@ -914,8 +917,10 @@ describe('NgModule', () => {
914917
}
915918

916919
const spy = spyOn(console, 'error');
917-
TestBed.configureTestingModule(
918-
{declarations: [MyComp, CustomEl], errorOnUnknownElements: true});
920+
TestBed.configureTestingModule({
921+
declarations: [MyComp, CustomEl],
922+
errorOnUnknownElements: true,
923+
});
919924

920925
const fixture = TestBed.createComponent(MyComp);
921926
fixture.detectChanges();
@@ -982,17 +987,13 @@ describe('NgModule', () => {
982987
const TOKEN_A = new InjectionToken('A');
983988
const TOKEN_B = new InjectionToken('B');
984989
@NgModule({
985-
providers: [
986-
{provide: TOKEN_A, useValue: 'TokenValueA'},
987-
]
990+
providers: [{provide: TOKEN_A, useValue: 'TokenValueA'}],
988991
})
989992
class AppModule {
990993
}
991994

992995
@NgModule({
993-
providers: [
994-
{provide: TOKEN_B, useValue: 'TokenValueB'},
995-
]
996+
providers: [{provide: TOKEN_B, useValue: 'TokenValueB'}],
996997
})
997998
class ChildModule {
998999
}
@@ -1039,7 +1040,6 @@ describe('NgModule', () => {
10391040
@NgModule({
10401041
declarations: [TestCmp],
10411042
exports: [TestCmp],
1042-
entryComponents: [TestCmp] // Only necessary for ViewEngine
10431043
})
10441044
class MyModule {
10451045
constructor(ngModuleRef: NgModuleRef<any>) {

0 commit comments

Comments
 (0)