@@ -12,133 +12,136 @@ import {MockResourceLoader} from '@angular/compiler/testing/src/resource_loader_
1212import { Component , Directive , Injectable , NgModule , OnDestroy , Pipe } from '@angular/core' ;
1313import { TestBed , async , getTestBed } from '@angular/core/testing' ;
1414import { expect } from '@angular/platform-browser/testing/src/matchers' ;
15- import { fixmeIvy } from '@angular/private/testing' ;
15+ import { obsoleteInIvy } from '@angular/private/testing' ;
1616
1717{
18- describe ( 'Jit Summaries' , ( ) => {
19- let instances : Map < any , Base > ;
20- let summaries : ( ) => any [ ] ;
21-
22- class SomeDep { }
23-
24- class Base {
25- static annotations : any [ ] ;
26- static parameters : any [ ] [ ] ;
27-
28- constructor ( public dep : SomeDep ) {
29- instances . set ( Object . getPrototypeOf ( this ) . constructor , this ) ;
30- }
31- }
32-
33- function expectInstanceCreated ( type : any ) {
34- const instance = instances . get ( type ) ! ;
35- expect ( instance ) . toBeDefined ( ) ;
36- expect ( instance . dep instanceof SomeDep ) . toBe ( true ) ;
37- }
38-
39- class SomeModule extends Base { }
40-
41- class SomePrivateComponent extends Base { }
42-
43- class SomePublicComponent extends Base { }
44-
45- class SomeDirective extends Base { }
46-
47- class SomePipe extends Base {
48- transform ( value : any ) { return value ; }
49- }
50-
51- class SomeService extends Base { }
52-
53- // Move back into the it which needs it after https://github.com/angular/tsickle/issues/547 is
54- // fixed.
55- @Component ( { template : '<div someDir>{{1 | somePipe}}</div>' } )
56- class TestComp3 {
57- constructor ( service : SomeService ) { }
58- }
59-
60- @Component ( { template : '' } )
61- class TestCompErrorOnDestroy implements OnDestroy {
62- ngOnDestroy ( ) { }
63- }
64-
65- function resetTestEnvironmentWithSummaries ( summaries ?: ( ) => any [ ] ) {
66- const { platform, ngModule} = getTestBed ( ) ;
67- TestBed . resetTestEnvironment ( ) ;
68- TestBed . initTestEnvironment ( ngModule , platform , summaries ) ;
69- }
70-
71- function createSummaries ( ) {
72- const resourceLoader = new MockResourceLoader ( ) ;
73-
74- setMetadata ( resourceLoader ) ;
75-
76- TestBed . configureCompiler ( { providers : [ { provide : ResourceLoader , useValue : resourceLoader } ] } ) ;
77- TestBed . configureTestingModule ( { imports : [ SomeModule ] , providers : [ SomeDep ] } ) ;
78-
79- let summariesPromise = TestBed . compileComponents ( ) . then ( ( ) => {
80- const metadataResolver = TestBed . get ( CompileMetadataResolver ) as CompileMetadataResolver ;
81- const summaries = [
82- metadataResolver . getNgModuleSummary ( SomeModule ) ,
83- // test nesting via closures, as we use this in the generated code too.
84- ( ) =>
85- [ metadataResolver . getDirectiveSummary ( SomePublicComponent ) ,
86- metadataResolver . getDirectiveSummary ( SomePrivateComponent ) ,
87- ] ,
88- metadataResolver . getDirectiveSummary ( SomeDirective ) ,
89- metadataResolver . getPipeSummary ( SomePipe ) ,
90- metadataResolver . getInjectableSummary ( SomeService )
91- ] ;
92- clearMetadata ( ) ;
93- TestBed . resetTestingModule ( ) ;
94- return ( ) => summaries ;
95- } ) ;
18+ obsoleteInIvy ( 'Summaries are not used/supported/able to be produced in Ivy. See FW-838.' )
19+ . describe ( 'Jit Summaries' , ( ) => {
20+ let instances : Map < any , Base > ;
21+ let summaries : ( ) => any [ ] ;
22+
23+ class SomeDep { }
24+
25+ class Base {
26+ static annotations : any [ ] ;
27+ static parameters : any [ ] [ ] ;
28+
29+ constructor ( public dep : SomeDep ) {
30+ instances . set ( Object . getPrototypeOf ( this ) . constructor , this ) ;
31+ }
32+ }
33+
34+ function expectInstanceCreated ( type : any ) {
35+ const instance = instances . get ( type ) ! ;
36+ expect ( instance ) . toBeDefined ( ) ;
37+ expect ( instance . dep instanceof SomeDep ) . toBe ( true ) ;
38+ }
39+
40+ class SomeModule extends Base { }
41+
42+ class SomePrivateComponent extends Base { }
43+
44+ class SomePublicComponent extends Base { }
45+
46+ class SomeDirective extends Base { }
47+
48+ class SomePipe extends Base {
49+ transform ( value : any ) { return value ; }
50+ }
51+
52+ class SomeService extends Base { }
53+
54+ // Move back into the it which needs it after https://github.com/angular/tsickle/issues/547
55+ // is
56+ // fixed.
57+ @Component ( { template : '<div someDir>{{1 | somePipe}}</div>' } )
58+ class TestComp3 {
59+ constructor ( service : SomeService ) { }
60+ }
61+
62+ @Component ( { template : '' } )
63+ class TestCompErrorOnDestroy implements OnDestroy {
64+ ngOnDestroy ( ) { }
65+ }
66+
67+ function resetTestEnvironmentWithSummaries ( summaries ?: ( ) => any [ ] ) {
68+ const { platform, ngModule} = getTestBed ( ) ;
69+ TestBed . resetTestEnvironment ( ) ;
70+ TestBed . initTestEnvironment ( ngModule , platform , summaries ) ;
71+ }
72+
73+ function createSummaries ( ) {
74+ const resourceLoader = new MockResourceLoader ( ) ;
75+
76+ setMetadata ( resourceLoader ) ;
77+
78+ TestBed . configureCompiler (
79+ { providers : [ { provide : ResourceLoader , useValue : resourceLoader } ] } ) ;
80+ TestBed . configureTestingModule ( { imports : [ SomeModule ] , providers : [ SomeDep ] } ) ;
81+
82+ let summariesPromise = TestBed . compileComponents ( ) . then ( ( ) => {
83+ const metadataResolver =
84+ TestBed . get ( CompileMetadataResolver ) as CompileMetadataResolver ;
85+ const summaries = [
86+ metadataResolver . getNgModuleSummary ( SomeModule ) ,
87+ // test nesting via closures, as we use this in the generated code too.
88+ ( ) =>
89+ [ metadataResolver . getDirectiveSummary ( SomePublicComponent ) ,
90+ metadataResolver . getDirectiveSummary ( SomePrivateComponent ) ,
91+ ] ,
92+ metadataResolver . getDirectiveSummary ( SomeDirective ) ,
93+ metadataResolver . getPipeSummary ( SomePipe ) ,
94+ metadataResolver . getInjectableSummary ( SomeService )
95+ ] ;
96+ clearMetadata ( ) ;
97+ TestBed . resetTestingModule ( ) ;
98+ return ( ) => summaries ;
99+ } ) ;
96100
97- resourceLoader . flush ( ) ;
98- return summariesPromise ;
99- }
101+ resourceLoader . flush ( ) ;
102+ return summariesPromise ;
103+ }
100104
101- function setMetadata ( resourceLoader : MockResourceLoader ) {
102- Base . parameters = [ [ SomeDep ] ] ;
105+ function setMetadata ( resourceLoader : MockResourceLoader ) {
106+ Base . parameters = [ [ SomeDep ] ] ;
103107
104- SomeModule . annotations = [ new NgModule ( {
105- declarations : [ SomePublicComponent , SomePrivateComponent , SomeDirective , SomePipe ] ,
106- exports : [ SomeDirective , SomePipe , SomePublicComponent ] ,
107- providers : [ SomeService ]
108- } ) ] ;
108+ SomeModule . annotations = [ new NgModule ( {
109+ declarations : [ SomePublicComponent , SomePrivateComponent , SomeDirective , SomePipe ] ,
110+ exports : [ SomeDirective , SomePipe , SomePublicComponent ] ,
111+ providers : [ SomeService ]
112+ } ) ] ;
109113
110- SomePublicComponent . annotations = [ new Component ( { templateUrl : 'somePublicUrl.html' } ) ] ;
111- resourceLoader . expect ( 'somePublicUrl.html' , `Hello public world!` ) ;
114+ SomePublicComponent . annotations = [ new Component ( { templateUrl : 'somePublicUrl.html' } ) ] ;
115+ resourceLoader . expect ( 'somePublicUrl.html' , `Hello public world!` ) ;
112116
113- SomePrivateComponent . annotations = [ new Component ( { templateUrl : 'somePrivateUrl.html' } ) ] ;
114- resourceLoader . expect ( 'somePrivateUrl.html' , `Hello private world!` ) ;
117+ SomePrivateComponent . annotations = [ new Component ( { templateUrl : 'somePrivateUrl.html' } ) ] ;
118+ resourceLoader . expect ( 'somePrivateUrl.html' , `Hello private world!` ) ;
115119
116- SomeDirective . annotations = [ new Directive ( { selector : '[someDir]' } ) ] ;
120+ SomeDirective . annotations = [ new Directive ( { selector : '[someDir]' } ) ] ;
117121
118- SomePipe . annotations = [ new Pipe ( { name : 'somePipe' } ) ] ;
122+ SomePipe . annotations = [ new Pipe ( { name : 'somePipe' } ) ] ;
119123
120- SomeService . annotations = [ new Injectable ( ) ] ;
121- }
124+ SomeService . annotations = [ new Injectable ( ) ] ;
125+ }
122126
123- function clearMetadata ( ) {
124- Base . parameters = [ ] ;
125- SomeModule . annotations = [ ] ;
126- SomePublicComponent . annotations = [ ] ;
127- SomePrivateComponent . annotations = [ ] ;
128- SomeDirective . annotations = [ ] ;
129- SomePipe . annotations = [ ] ;
130- SomeService . annotations = [ ] ;
131- }
127+ function clearMetadata ( ) {
128+ Base . parameters = [ ] ;
129+ SomeModule . annotations = [ ] ;
130+ SomePublicComponent . annotations = [ ] ;
131+ SomePrivateComponent . annotations = [ ] ;
132+ SomeDirective . annotations = [ ] ;
133+ SomePipe . annotations = [ ] ;
134+ SomeService . annotations = [ ] ;
135+ }
132136
133- beforeEach ( async ( ( ) => {
134- instances = new Map < any , any > ( ) ;
135- createSummaries ( ) . then ( s => summaries = s ) ;
136- } ) ) ;
137+ beforeEach ( async ( ( ) => {
138+ instances = new Map < any , any > ( ) ;
139+ createSummaries ( ) . then ( s => summaries = s ) ;
140+ } ) ) ;
137141
138- afterEach ( ( ) => { resetTestEnvironmentWithSummaries ( ) ; } ) ;
142+ afterEach ( ( ) => { resetTestEnvironmentWithSummaries ( ) ; } ) ;
139143
140- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
141- . it ( 'should use directive metadata from summaries' , ( ) => {
144+ it ( 'should use directive metadata from summaries' , ( ) => {
142145 resetTestEnvironmentWithSummaries ( summaries ) ;
143146
144147 @Component ( { template : '<div someDir></div>' } )
@@ -152,8 +155,8 @@ import {fixmeIvy} from '@angular/private/testing';
152155 expectInstanceCreated ( SomeDirective ) ;
153156 } ) ;
154157
155- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
156- . it ( 'should use pipe metadata from summaries' , ( ) => {
158+
159+ it ( 'should use pipe metadata from summaries' , ( ) => {
157160 resetTestEnvironmentWithSummaries ( summaries ) ;
158161
159162 @Component ( { template : '{{1 | somePipe}}' } )
@@ -165,8 +168,7 @@ import {fixmeIvy} from '@angular/private/testing';
165168 expectInstanceCreated ( SomePipe ) ;
166169 } ) ;
167170
168- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
169- . it ( 'should use Service metadata from summaries' , ( ) => {
171+ it ( 'should use Service metadata from summaries' , ( ) => {
170172 resetTestEnvironmentWithSummaries ( summaries ) ;
171173
172174 TestBed . configureTestingModule ( {
@@ -176,8 +178,7 @@ import {fixmeIvy} from '@angular/private/testing';
176178 expectInstanceCreated ( SomeService ) ;
177179 } ) ;
178180
179- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
180- . it ( 'should use NgModule metadata from summaries' , ( ) => {
181+ it ( 'should use NgModule metadata from summaries' , ( ) => {
181182 resetTestEnvironmentWithSummaries ( summaries ) ;
182183
183184 TestBed
@@ -191,17 +192,15 @@ import {fixmeIvy} from '@angular/private/testing';
191192 expectInstanceCreated ( SomeService ) ;
192193 } ) ;
193194
194- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
195- . it ( 'should allow to create private components from imported NgModule summaries' , ( ) => {
195+ it ( 'should allow to create private components from imported NgModule summaries' , ( ) => {
196196 resetTestEnvironmentWithSummaries ( summaries ) ;
197197
198198 TestBed . configureTestingModule ( { providers : [ SomeDep ] , imports : [ SomeModule ] } )
199199 . createComponent ( SomePrivateComponent ) ;
200200 expectInstanceCreated ( SomePrivateComponent ) ;
201201 } ) ;
202202
203- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
204- . it ( 'should throw when trying to mock a type with a summary' , ( ) => {
203+ it ( 'should throw when trying to mock a type with a summary' , ( ) => {
205204 resetTestEnvironmentWithSummaries ( summaries ) ;
206205
207206 TestBed . resetTestingModule ( ) ;
@@ -220,35 +219,33 @@ import {fixmeIvy} from '@angular/private/testing';
220219 . toThrowError ( 'SomeModule was AOT compiled, so its metadata cannot be changed.' ) ;
221220 } ) ;
222221
223- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
224- . it ( 'should return stack trace and component data on resetTestingModule when error is thrown' ,
225- ( ) => {
226- resetTestEnvironmentWithSummaries ( ) ;
222+ it ( 'should return stack trace and component data on resetTestingModule when error is thrown' ,
223+ ( ) => {
224+ resetTestEnvironmentWithSummaries ( ) ;
227225
228- const fixture =
229- TestBed . configureTestingModule ( { declarations : [ TestCompErrorOnDestroy ] } )
230- . createComponent < TestCompErrorOnDestroy > ( TestCompErrorOnDestroy ) ;
226+ const fixture =
227+ TestBed . configureTestingModule ( { declarations : [ TestCompErrorOnDestroy ] } )
228+ . createComponent < TestCompErrorOnDestroy > ( TestCompErrorOnDestroy ) ;
231229
232- const expectedError = 'Error from ngOnDestroy' ;
230+ const expectedError = 'Error from ngOnDestroy' ;
233231
234- const component : TestCompErrorOnDestroy = fixture . componentInstance ;
232+ const component : TestCompErrorOnDestroy = fixture . componentInstance ;
235233
236- spyOn ( console , 'error' ) ;
237- spyOn ( component , 'ngOnDestroy' ) . and . throwError ( expectedError ) ;
234+ spyOn ( console , 'error' ) ;
235+ spyOn ( component , 'ngOnDestroy' ) . and . throwError ( expectedError ) ;
238236
239- const expectedObject = {
240- stacktrace : new Error ( expectedError ) ,
241- component,
242- } ;
237+ const expectedObject = {
238+ stacktrace : new Error ( expectedError ) ,
239+ component,
240+ } ;
243241
244- TestBed . resetTestingModule ( ) ;
242+ TestBed . resetTestingModule ( ) ;
245243
246- expect ( console . error )
247- . toHaveBeenCalledWith ( 'Error during cleanup of component' , expectedObject ) ;
248- } ) ;
244+ expect ( console . error )
245+ . toHaveBeenCalledWith ( 'Error during cleanup of component' , expectedObject ) ;
246+ } ) ;
249247
250- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
251- . it ( 'should allow to add summaries via configureTestingModule' , ( ) => {
248+ it ( 'should allow to add summaries via configureTestingModule' , ( ) => {
252249 resetTestEnvironmentWithSummaries ( ) ;
253250
254251 @Component ( { template : '<div someDir></div>' } )
@@ -265,8 +262,7 @@ import {fixmeIvy} from '@angular/private/testing';
265262 expectInstanceCreated ( SomeDirective ) ;
266263 } ) ;
267264
268- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
269- . it ( 'should allow to override a provider' , ( ) => {
265+ it ( 'should allow to override a provider' , ( ) => {
270266 resetTestEnvironmentWithSummaries ( summaries ) ;
271267
272268 const overwrittenValue = { } ;
@@ -279,8 +275,7 @@ import {fixmeIvy} from '@angular/private/testing';
279275 expect ( fixture . componentInstance . dep ) . toBe ( overwrittenValue ) ;
280276 } ) ;
281277
282- fixmeIvy ( 'FW-838: ivy testbed doesn\'t support jit summaries' )
283- . it ( 'should allow to override a template' , ( ) => {
278+ it ( 'should allow to override a template' , ( ) => {
284279 resetTestEnvironmentWithSummaries ( summaries ) ;
285280
286281 TestBed . overrideTemplateUsingTestingModule ( SomePublicComponent , 'overwritten' ) ;
@@ -292,5 +287,5 @@ import {fixmeIvy} from '@angular/private/testing';
292287
293288 expect ( fixture . nativeElement ) . toHaveText ( 'overwritten' ) ;
294289 } ) ;
295- } ) ;
290+ } ) ;
296291}
0 commit comments