| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {Component, NgModule} from '@angular/core'; | 
					
						
							|  |  |  | import {BrowserModule} from '@angular/platform-browser'; | 
					
						
							|  |  |  | import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  | import {withBody} from '@angular/private/testing'; | 
					
						
							| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('bootstrap', () => { | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  |   it('should bootstrap using #id selector', | 
					
						
							|  |  |  |      withBody('<div>before|</div><button id="my-app"></button>', async() => { | 
					
						
							| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  |        try { | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  |          const ngModuleRef = await platformBrowserDynamic().bootstrapModule(IdSelectorAppModule); | 
					
						
							|  |  |  |          expect(document.body.textContent).toEqual('before|works!'); | 
					
						
							|  |  |  |          ngModuleRef.destroy(); | 
					
						
							|  |  |  |        } catch (err) { | 
					
						
							|  |  |  |          console.error(err); | 
					
						
							|  |  |  |        } | 
					
						
							|  |  |  |      })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it('should bootstrap using one of selectors from the list', | 
					
						
							|  |  |  |      withBody('<div>before|</div><div class="bar"></div>', async() => { | 
					
						
							|  |  |  |        try { | 
					
						
							|  |  |  |          const ngModuleRef = | 
					
						
							|  |  |  |              await platformBrowserDynamic().bootstrapModule(MultipleSelectorsAppModule); | 
					
						
							|  |  |  |          expect(document.body.textContent).toEqual('before|works!'); | 
					
						
							| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  |          ngModuleRef.destroy(); | 
					
						
							|  |  |  |        } catch (err) { | 
					
						
							|  |  |  |          console.error(err); | 
					
						
							|  |  |  |        } | 
					
						
							|  |  |  |      })); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: '#my-app', | 
					
						
							|  |  |  |   template: 'works!', | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  | export class IdSelectorAppComponent { | 
					
						
							| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  | @NgModule({ | 
					
						
							|  |  |  |   imports: [BrowserModule], | 
					
						
							|  |  |  |   declarations: [IdSelectorAppComponent], | 
					
						
							|  |  |  |   bootstrap: [IdSelectorAppComponent], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class IdSelectorAppModule { | 
					
						
							| 
									
										
										
										
											2019-11-12 21:32:58 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-18 14:35:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: '[foo],span,.bar', | 
					
						
							|  |  |  |   template: 'works!', | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class MultipleSelectorsAppComponent { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @NgModule({ | 
					
						
							|  |  |  |   imports: [BrowserModule], | 
					
						
							|  |  |  |   declarations: [MultipleSelectorsAppComponent], | 
					
						
							|  |  |  |   bootstrap: [MultipleSelectorsAppComponent], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class MultipleSelectorsAppModule { | 
					
						
							|  |  |  | } |