7
7
*/
8
8
9
9
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' ;
11
11
import { KNOWN_CONTROL_FLOW_DIRECTIVES } from '@angular/core/src/render3/instructions/element_validation' ;
12
12
import { TestBed } from '@angular/core/testing' ;
13
13
import { BrowserModule } from '@angular/platform-browser' ;
@@ -249,10 +249,10 @@ describe('NgModule', () => {
249
249
@Component ( {
250
250
selector : 'my-comp' ,
251
251
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
+ ` ,
256
256
} )
257
257
class MyComp {
258
258
condition = true ;
@@ -278,9 +278,7 @@ describe('NgModule', () => {
278
278
it ( 'should log an error on unknown props of `ng-template` if NO_ERRORS_SCHEMA is absent' , ( ) => {
279
279
@Component ( {
280
280
selector : 'my-comp' ,
281
- template : `
282
- <ng-template *ngIf="condition"></ng-template>
283
- ` ,
281
+ template : ` <ng-template *ngIf="condition"></ng-template> ` ,
284
282
} )
285
283
class MyComp {
286
284
condition = true ;
@@ -306,9 +304,7 @@ describe('NgModule', () => {
306
304
it ( 'should log an error on unknown props of `ng-container` if NO_ERRORS_SCHEMA is absent' , ( ) => {
307
305
@Component ( {
308
306
selector : 'my-comp' ,
309
- template : `
310
- <ng-container *ngIf="condition"></ng-container>
311
- ` ,
307
+ template : ` <ng-container *ngIf="condition"></ng-container> ` ,
312
308
} )
313
309
class MyComp {
314
310
condition = true ;
@@ -334,9 +330,7 @@ describe('NgModule', () => {
334
330
it ( 'should log an error on unknown props of `ng-content` if NO_ERRORS_SCHEMA is absent' , ( ) => {
335
331
@Component ( {
336
332
selector : 'my-comp' ,
337
- template : `
338
- <ng-content *ngIf="condition"></ng-content>
339
- ` ,
333
+ template : ` <ng-content *ngIf="condition"></ng-content> ` ,
340
334
} )
341
335
class MyComp {
342
336
condition = true ;
@@ -364,10 +358,10 @@ describe('NgModule', () => {
364
358
@Component ( {
365
359
selector : 'my-comp' ,
366
360
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
+ ` ,
371
365
} )
372
366
class MyComp {
373
367
condition = true ;
@@ -483,7 +477,7 @@ describe('NgModule', () => {
483
477
@Component ( {
484
478
template : `<custom-el></custom-el>` ,
485
479
standalone : true ,
486
- schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
480
+ schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
487
481
} )
488
482
class MyComp {
489
483
}
@@ -629,9 +623,9 @@ describe('NgModule', () => {
629
623
`NG0303: Can't bind to 'unknownProp' since it isn't a known property of 'may-be-web-component' \\(used in the 'MyComp' component template\\).` ,
630
624
`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.` ,
631
625
`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.` ,
633
627
] ;
634
- lines . forEach ( line => expect ( errorMessage ) . toMatch ( line ) ) ;
628
+ lines . forEach ( ( line ) => expect ( errorMessage ) . toMatch ( line ) ) ;
635
629
} ) ;
636
630
637
631
KNOWN_CONTROL_FLOW_DIRECTIVES . forEach ( ( correspondingImport , directive ) => {
@@ -664,9 +658,9 @@ describe('NgModule', () => {
664
658
directive } ' since it isn't a known property of 'div' \\(used in the 'App' component template\\).`,
665
659
`If the '${ directive } ' is an Angular control flow directive, please make sure ` +
666
660
`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.`,
668
662
] ;
669
- lines . forEach ( line => expect ( errorMessage ) . toMatch ( line ) ) ;
663
+ lines . forEach ( ( line ) => expect ( errorMessage ) . toMatch ( line ) ) ;
670
664
} ) ;
671
665
672
666
it ( `should produce a warning when the '${ directive } ' directive ` +
@@ -692,9 +686,9 @@ describe('NgModule', () => {
692
686
directive } ' since it isn't a known property of 'div' \\(used in the 'App' component template\\).`,
693
687
`If the '${ directive } ' is an Angular control flow directive, please make sure ` +
694
688
`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.`,
696
690
] ;
697
- lines . forEach ( line => expect ( errorMessage ) . toMatch ( line ) ) ;
691
+ lines . forEach ( ( line ) => expect ( errorMessage ) . toMatch ( line ) ) ;
698
692
} ) ;
699
693
} ) ;
700
694
@@ -710,16 +704,17 @@ describe('NgModule', () => {
710
704
vars,
711
705
consts,
712
706
template,
713
- encapsulation : 2
707
+ encapsulation : 2 ,
714
708
} ) ;
715
709
}
716
710
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
+ ] ,
723
718
null , null ) ;
724
719
return Comp ;
725
720
}
@@ -730,13 +725,18 @@ describe('NgModule', () => {
730
725
static ɵinj = defineInjector ( { } ) ;
731
726
}
732
727
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
+ ] ,
740
740
null , null ) ;
741
741
return Module ;
742
742
}
@@ -839,7 +839,7 @@ describe('NgModule', () => {
839
839
TestBed . configureTestingModule ( {
840
840
declarations : [ MyComp ] ,
841
841
schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
842
- errorOnUnknownElements : true
842
+ errorOnUnknownElements : true ,
843
843
} ) ;
844
844
845
845
const fixture = TestBed . createComponent ( MyComp ) ;
@@ -871,8 +871,11 @@ describe('NgModule', () => {
871
871
}
872
872
873
873
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
+ } ) ;
876
879
877
880
const fixture = TestBed . createComponent ( MyComp ) ;
878
881
fixture . detectChanges ( ) ;
@@ -914,8 +917,10 @@ describe('NgModule', () => {
914
917
}
915
918
916
919
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
+ } ) ;
919
924
920
925
const fixture = TestBed . createComponent ( MyComp ) ;
921
926
fixture . detectChanges ( ) ;
@@ -982,17 +987,13 @@ describe('NgModule', () => {
982
987
const TOKEN_A = new InjectionToken ( 'A' ) ;
983
988
const TOKEN_B = new InjectionToken ( 'B' ) ;
984
989
@NgModule ( {
985
- providers : [
986
- { provide : TOKEN_A , useValue : 'TokenValueA' } ,
987
- ]
990
+ providers : [ { provide : TOKEN_A , useValue : 'TokenValueA' } ] ,
988
991
} )
989
992
class AppModule {
990
993
}
991
994
992
995
@NgModule ( {
993
- providers : [
994
- { provide : TOKEN_B , useValue : 'TokenValueB' } ,
995
- ]
996
+ providers : [ { provide : TOKEN_B , useValue : 'TokenValueB' } ] ,
996
997
} )
997
998
class ChildModule {
998
999
}
@@ -1039,7 +1040,6 @@ describe('NgModule', () => {
1039
1040
@NgModule ( {
1040
1041
declarations : [ TestCmp ] ,
1041
1042
exports : [ TestCmp ] ,
1042
- entryComponents : [ TestCmp ] // Only necessary for ViewEngine
1043
1043
} )
1044
1044
class MyModule {
1045
1045
constructor ( ngModuleRef : NgModuleRef < any > ) {
0 commit comments