| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  | import { | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   stringifyElement | 
					
						
							|  |  |  | } from 'angular2/test_lib'; | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | import {MapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {ViewSplitter} from 'angular2/src/render/dom/compiler/view_splitter'; | 
					
						
							|  |  |  | import {CompilePipeline} from 'angular2/src/render/dom/compiler/compile_pipeline'; | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  | import {CompileElement} from 'angular2/src/render/dom/compiler/compile_element'; | 
					
						
							|  |  |  | import {ProtoViewDto, ViewType, ViewDefinition} from 'angular2/src/render/api'; | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | import {DOM} from 'angular2/src/dom/dom_adapter'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-11 17:26:48 +02:00
										 |  |  | import {Lexer, Parser} from 'angular2/src/change_detection/change_detection'; | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('ViewSplitter', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |     function createViewDefinition(): ViewDefinition { | 
					
						
							|  |  |  |       return new ViewDefinition({componentId: 'someComponent'}); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |     function createPipeline() { | 
					
						
							|  |  |  |       return new CompilePipeline([new ViewSplitter(new Parser(new Lexer()))]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |     function proceess(el): CompileElement[] { | 
					
						
							|  |  |  |       return createPipeline().processElements(el, ViewType.COMPONENT, createViewDefinition()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |     describe('<template> elements', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should move the content into a new <template> element and mark that as viewRoot', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<template if="true">a</template>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[1].element)) | 
					
						
							|  |  |  |             .toEqual('<template class="ng-binding" if="true"></template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[1].isViewRoot).toBe(false); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[2].element)).toEqual('<template>a</template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should mark the new <template> element as viewRoot', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<template if="true">a</template>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should not wrap the root element', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate(''); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results.length).toBe(1); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         expect(stringifyElement(rootElement)).toEqual('<template></template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should copy over the elementDescription', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<template if="true">a</template>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].elementDescription).toBe(results[1].elementDescription); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should clean out the inheritedElementBinder', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<template if="true">a</template>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedElementBinder).toBe(null); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should create a nestedProtoView', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<template if="true">a</template>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedProtoView).not.toBe(null); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         expect(results[2].inheritedProtoView) | 
					
						
							|  |  |  |             .toBe(results[1].inheritedElementBinder.nestedProtoView); | 
					
						
							| 
									
										
										
										
											2015-06-09 15:20:33 +02:00
										 |  |  |         expect(results[2].inheritedProtoView.type).toBe(ViewType.EMBEDDED); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[2].inheritedProtoView.rootElement)) | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |             .toEqual('<template>a</template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('elements with template attribute', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should replace the element with an empty <template> element', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span template=""></span>'); | 
					
						
							|  |  |  |         var originalChild = DOM.firstChild(DOM.content(rootElement)); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[0].element).toBe(rootElement); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[0].element)) | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |             .toEqual('<template><template class="ng-binding"></template></template>'); | 
					
						
							|  |  |  |         expect(stringifyElement(results[2].element)) | 
					
						
							|  |  |  |             .toEqual('<template><span template=""></span></template>'); | 
					
						
							|  |  |  |         expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should work with top-level template node', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template>x</div>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         var originalChild = DOM.content(rootElement).childNodes[0]; | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(results[0].element).toBe(rootElement); | 
					
						
							|  |  |  |         expect(results[0].isViewRoot).toBe(true); | 
					
						
							|  |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[0].element)) | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |             .toEqual('<template><template class="ng-binding"></template></template>'); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should mark the element as viewRoot', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add property bindings from the template attribute', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template="some-prop:expr"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].inheritedElementBinder.propertyBindings.get('someProp').source) | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |             .toEqual('expr'); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].attrs().get('some-prop')).toEqual('expr'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add variable mappings from the template attribute to the nestedProtoView', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template="var var-name=mapName"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         expect(results[2].inheritedProtoView.variableBindings) | 
					
						
							|  |  |  |             .toEqual(MapWrapper.createFromStringMap({'mapName': 'varName'})); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add entries without value as attributes to the element', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template="varname"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].attrs().get('varname')).toEqual(''); | 
					
						
							|  |  |  |         expect(results[1].inheritedElementBinder.propertyBindings).toEqual(new Map()); | 
					
						
							|  |  |  |         expect(results[1].inheritedElementBinder.variableBindings).toEqual(new Map()); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should iterate properly after a template dom modification', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div template></div><after></after>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         // 1 root + 2 initial + 2 generated template elements
 | 
					
						
							|  |  |  |         expect(results.length).toEqual(5); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should copy over the elementDescription', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span template=""></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].elementDescription).toBe(results[1].elementDescription); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should clean out the inheritedElementBinder', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span template=""></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedElementBinder).toBe(null); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should create a nestedProtoView', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span template=""></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedProtoView).not.toBe(null); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         expect(results[2].inheritedProtoView) | 
					
						
							|  |  |  |             .toBe(results[1].inheritedElementBinder.nestedProtoView); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[2].inheritedProtoView.rootElement)) | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |             .toEqual('<template><span template=""></span></template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('elements with *directive_name attribute', () => { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should replace the element with an empty <template> element', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span *ng-if></span>'); | 
					
						
							|  |  |  |         var originalChild = DOM.firstChild(DOM.content(rootElement)); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[0].element).toBe(rootElement); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[0].element)) | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |             .toEqual('<template><template class="ng-binding" ng-if=""></template></template>'); | 
					
						
							|  |  |  |         expect(stringifyElement(results[2].element)) | 
					
						
							|  |  |  |             .toEqual('<template><span *ng-if=""></span></template>'); | 
					
						
							|  |  |  |         expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should mark the element as viewRoot', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *foo="bar"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should work with top-level template node', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *foo>x</div>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         var originalChild = DOM.content(rootElement).childNodes[0]; | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(results[0].element).toBe(rootElement); | 
					
						
							|  |  |  |         expect(results[0].isViewRoot).toBe(true); | 
					
						
							|  |  |  |         expect(results[2].isViewRoot).toBe(true); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[0].element)) | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |             .toEqual('<template><template class="ng-binding" foo=""></template></template>'); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         expect(DOM.firstChild(DOM.content(results[2].element))).toBe(originalChild); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add property bindings from the template attribute', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *prop="expr"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].inheritedElementBinder.propertyBindings.get('prop').source) | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |             .toEqual('expr'); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].attrs().get('prop')).toEqual('expr'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add variable mappings from the template attribute to the nestedProtoView', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *foreach="var varName=mapName"></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         expect(results[2].inheritedProtoView.variableBindings) | 
					
						
							|  |  |  |             .toEqual(MapWrapper.createFromStringMap({'mapName': 'varName'})); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should add entries without value as attribute to the element', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *varname></div>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |         expect(results[1].attrs().get('varname')).toEqual(''); | 
					
						
							|  |  |  |         expect(results[1].inheritedElementBinder.propertyBindings).toEqual(new Map()); | 
					
						
							|  |  |  |         expect(results[1].inheritedElementBinder.variableBindings).toEqual(new Map()); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should iterate properly after a template dom modification', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<div *foo></div><after></after>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         // 1 root + 2 initial + 2 generated template elements
 | 
					
						
							|  |  |  |         expect(results.length).toEqual(5); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should copy over the elementDescription', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span *foo></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].elementDescription).toBe(results[1].elementDescription); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should clean out the inheritedElementBinder', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span *foo></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedElementBinder).toBe(null); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should create a nestedProtoView', () => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |         var rootElement = DOM.createTemplate('<span *foo></span>'); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         var results = proceess(rootElement); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |         expect(results[2].inheritedProtoView).not.toBe(null); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |         expect(results[2].inheritedProtoView) | 
					
						
							|  |  |  |             .toBe(results[1].inheritedElementBinder.nestedProtoView); | 
					
						
							| 
									
										
										
										
											2015-05-22 17:47:13 +02:00
										 |  |  |         expect(stringifyElement(results[2].inheritedProtoView.rootElement)) | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |             .toEqual('<template><span *foo=""></span></template>'); | 
					
						
							| 
									
										
										
										
											2015-03-23 14:10:55 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |