| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | import { | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   xdescribe, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   afterEach, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   beforeEachProviders, | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | } from '@angular/core/testing/testing_internal'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {IS_DART} from '../src/facade/lang'; | 
					
						
							|  |  |  | import {Injector} from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {ComponentFactory} from '@angular/core/src/linker/component_factory'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | import * as typed from './offline_compiler_codegen_typed'; | 
					
						
							|  |  |  | import * as untyped from './offline_compiler_codegen_untyped'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; | 
					
						
							|  |  |  | import {SharedStylesHost} from '@angular/platform-browser/src/dom/shared_styles_host'; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | import {CompA} from './offline_compiler_util'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							| 
									
										
										
										
											2016-04-13 17:05:17 -07:00
										 |  |  |   var typedComponentFactory = typed.CompANgFactory; | 
					
						
							|  |  |  |   var untypedComponentFactory = untyped.CompANgFactory; | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  |   var fixtures: TestFixture[] = []; | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  |   if (IS_DART || !getDOM().supportsDOMEvents()) { | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |     // Our generator only works on node.js and Dart...
 | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  |     fixtures.push(new TestFixture(typedComponentFactory, 'typed')); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (!IS_DART) { | 
					
						
							|  |  |  |     // Our generator only works on node.js and Dart...
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  |     if (!getDOM().supportsDOMEvents()) { | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  |       fixtures.push(new TestFixture(untypedComponentFactory, 'untyped')); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   describe('OfflineCompiler', () => { | 
					
						
							|  |  |  |     var injector: Injector; | 
					
						
							|  |  |  |     var sharedStylesHost: SharedStylesHost; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-13 17:05:17 -07:00
										 |  |  |     beforeEach(inject([Injector, SharedStylesHost], (_injector, _sharedStylesHost) => { | 
					
						
							|  |  |  |       injector = _injector; | 
					
						
							|  |  |  |       sharedStylesHost = _sharedStylesHost; | 
					
						
							|  |  |  |     })); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  |     fixtures.forEach((fixture) => { | 
					
						
							|  |  |  |       describe(`${fixture.name}`, () => { | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |         it('should compile components', () => { | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  |           var hostEl = fixture.compFactory.create(injector); | 
					
						
							|  |  |  |           expect(hostEl.instance).toBeAnInstanceOf(CompA); | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  |           var styles = sharedStylesHost.getAllStyles(); | 
					
						
							|  |  |  |           expect(styles[0]).toContain('.redStyle[_ngcontent'); | 
					
						
							|  |  |  |           expect(styles[1]).toContain('.greenStyle[_ngcontent'); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-04-30 10:52:04 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TestFixture { | 
					
						
							|  |  |  |   constructor(public compFactory: ComponentFactory<CompA>, public name: string) {} | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:03 -07:00
										 |  |  | } |