@@ -65,30 +65,29 @@ describe('jit source mapping', () => {
6565 function declareTests ( { ngUrl, templateDecorator} : TestConfig ) {
6666 const generatedUrl = 'ng:///MyComp.js' ;
6767
68- it ( 'should use the right source url in html parse errors' , fakeAsync ( ( ) => {
69- const template = '<div>\n </error>' ;
70- @Component ( { ...templateDecorator ( template ) } )
71- class MyComp {
72- }
68+ it ( 'should use the right source url in html parse errors' , async ( ) => {
69+ const template = '<div>\n </error>' ;
70+ @Component ( { ...templateDecorator ( template ) } )
71+ class MyComp {
72+ }
7373
74- expect ( ( ) => {
75- resolveCompileAndCreateComponent ( MyComp , template ) ;
76- } ) . toThrowError ( new RegExp ( `${ escapeRegExp ( ngUrl ) } @1:2` ) ) ;
77- } ) ) ;
74+ await expectAsync ( resolveCompileAndCreateComponent ( MyComp , template ) )
75+ . toBeRejectedWithError ( new RegExp ( `${ escapeRegExp ( ngUrl ) } @1:2` ) ) ;
76+ } ) ;
7877
79- it ( 'should create a sourceMap for templates' , fakeAsync ( ( ) => {
80- const template = `Hello World!` ;
78+ it ( 'should create a sourceMap for templates' , async ( ) => {
79+ const template = `Hello World!` ;
8180
82- @Component ( { ...templateDecorator ( template ) } )
83- class MyComp {
84- }
81+ @Component ( { ...templateDecorator ( template ) } )
82+ class MyComp {
83+ }
8584
86- resolveCompileAndCreateComponent ( MyComp , template ) ;
85+ await resolveCompileAndCreateComponent ( MyComp , template ) ;
8786
88- const sourceMap = jitEvaluator . getSourceMap ( generatedUrl ) ;
89- expect ( sourceMap . sources ) . toEqual ( [ generatedUrl , ngUrl ] ) ;
90- expect ( sourceMap . sourcesContent ) . toEqual ( [ ' ' , template ] ) ;
91- } ) ) ;
87+ const sourceMap = jitEvaluator . getSourceMap ( generatedUrl ) ;
88+ expect ( sourceMap . sources ) . toEqual ( [ generatedUrl , ngUrl ] ) ;
89+ expect ( sourceMap . sourcesContent ) . toEqual ( [ ' ' , template ] ) ;
90+ } ) ;
9291
9392
9493 it ( 'should report source location for di errors' , async ( ) => {
@@ -108,7 +107,7 @@ describe('jit source mapping', () => {
108107 TestBed . configureTestingModule ( { declarations : [ SomeDir ] } ) ;
109108 let error : any ;
110109 try {
111- resolveCompileAndCreateComponent ( MyComp , template ) ;
110+ await resolveCompileAndCreateComponent ( MyComp , template ) ;
112111 } catch ( e ) {
113112 error = e ;
114113 }
@@ -139,7 +138,7 @@ describe('jit source mapping', () => {
139138 TestBed . configureTestingModule ( { declarations : [ SomeDir ] } ) ;
140139 let error : any ;
141140 try {
142- resolveCompileAndCreateComponent ( MyComp , template ) ;
141+ await resolveCompileAndCreateComponent ( MyComp , template ) ;
143142 } catch ( e ) {
144143 error = e ;
145144 }
@@ -161,7 +160,7 @@ describe('jit source mapping', () => {
161160 }
162161 }
163162
164- const comp = resolveCompileAndCreateComponent ( MyComp , template ) ;
163+ const comp = await resolveCompileAndCreateComponent ( MyComp , template ) ;
165164
166165 let error : any ;
167166 try {
@@ -187,7 +186,7 @@ describe('jit source mapping', () => {
187186 }
188187 }
189188
190- const comp = resolveCompileAndCreateComponent ( MyComp , template ) ;
189+ const comp = await resolveCompileAndCreateComponent ( MyComp , template ) ;
191190
192191 let error : any ;
193192 const errorHandler = TestBed . inject ( ErrorHandler ) ;
@@ -208,28 +207,25 @@ describe('jit source mapping', () => {
208207 }
209208 } ) ;
210209
211- function compileAndCreateComponent ( comType : any ) {
210+ async function compileAndCreateComponent ( comType : any ) {
212211 TestBed . configureTestingModule ( { declarations : [ comType ] } ) ;
213212
214- let error : any ;
215- TestBed . compileComponents ( ) . catch ( ( e ) => error = e ) ;
213+ await TestBed . compileComponents ( ) ;
214+
216215 if ( resourceLoader . hasPendingRequests ( ) ) {
217216 resourceLoader . flush ( ) ;
218217 }
219- tick ( ) ;
220- if ( error ) {
221- throw error ;
222- }
218+
223219 return TestBed . createComponent ( comType ) ;
224220 }
225221
226222 function createResolver ( contents : string ) {
227223 return ( _url : string ) => Promise . resolve ( contents ) ;
228224 }
229225
230- function resolveCompileAndCreateComponent ( comType : any , template : string ) {
231- resolveComponentResources ( createResolver ( template ) ) ;
232- return compileAndCreateComponent ( comType ) ;
226+ async function resolveCompileAndCreateComponent ( comType : any , template : string ) {
227+ await resolveComponentResources ( createResolver ( template ) ) ;
228+ return await compileAndCreateComponent ( comType ) ;
233229 }
234230
235231 let ɵcompilerFacade : CompilerFacade ;
0 commit comments