| 
									
										
										
										
											2016-06-23 09:47:54 -07: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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-27 17:12:25 -07:00
										 |  |  | import {beforeEach, describe, expect, inject, it} from '../../../core/testing/testing_internal'; | 
					
						
							| 
									
										
										
										
											2016-08-01 12:19:09 -07:00
										 |  |  | import {Element} from '../../src/ml_parser/ast'; | 
					
						
							|  |  |  | import {HtmlParser} from '../../src/ml_parser/html_parser'; | 
					
						
							| 
									
										
										
										
											2016-07-21 11:41:25 -07:00
										 |  |  | import {PreparsedElement, PreparsedElementType, preparseElement} from '../../src/template_parser/template_preparser'; | 
					
						
							| 
									
										
										
										
											2015-09-18 10:33:23 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('preparseElement', () => { | 
					
						
							| 
									
										
										
										
											2016-11-12 14:08:58 +01:00
										 |  |  |     let htmlParser: HtmlParser; | 
					
						
							| 
									
										
										
										
											2015-09-18 10:33:23 -07:00
										 |  |  |     beforeEach(inject([HtmlParser], (_htmlParser: HtmlParser) => { htmlParser = _htmlParser; })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function preparse(html: string): PreparsedElement { | 
					
						
							| 
									
										
										
										
											2016-07-21 13:56:58 -07:00
										 |  |  |       return preparseElement(htmlParser.parse(html, 'TestComp').rootNodes[0] as Element); | 
					
						
							| 
									
										
										
										
											2015-09-18 10:33:23 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should detect script elements', inject([HtmlParser], (htmlParser: HtmlParser) => { | 
					
						
							|  |  |  |          expect(preparse('<script>').type).toBe(PreparsedElementType.SCRIPT); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should detect style elements', inject([HtmlParser], (htmlParser: HtmlParser) => { | 
					
						
							|  |  |  |          expect(preparse('<style>').type).toBe(PreparsedElementType.STYLE); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should detect stylesheet elements', inject([HtmlParser], (htmlParser: HtmlParser) => { | 
					
						
							|  |  |  |          expect(preparse('<link rel="stylesheet">').type).toBe(PreparsedElementType.STYLESHEET); | 
					
						
							|  |  |  |          expect(preparse('<link rel="stylesheet" href="someUrl">').hrefAttr).toEqual('someUrl'); | 
					
						
							|  |  |  |          expect(preparse('<link rel="someRel">').type).toBe(PreparsedElementType.OTHER); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should detect ng-content elements', inject([HtmlParser], (htmlParser: HtmlParser) => { | 
					
						
							|  |  |  |          expect(preparse('<ng-content>').type).toBe(PreparsedElementType.NG_CONTENT); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should normalize ng-content.select attribute', | 
					
						
							|  |  |  |        inject([HtmlParser], (htmlParser: HtmlParser) => { | 
					
						
							|  |  |  |          expect(preparse('<ng-content>').selectAttr).toEqual('*'); | 
					
						
							|  |  |  |          expect(preparse('<ng-content select>').selectAttr).toEqual('*'); | 
					
						
							|  |  |  |          expect(preparse('<ng-content select="*">').selectAttr).toEqual('*'); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-23 14:15:05 -07:00
										 |  |  |     it('should extract ngProjectAs value', () => { | 
					
						
							|  |  |  |       expect(preparse('<p ngProjectAs="el[attr].class"></p>').projectAs).toEqual('el[attr].class'); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-09-18 10:33:23 -07:00
										 |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-10-02 07:57:29 -07:00
										 |  |  | } |