| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							|  |  |  |   beforeEach, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  |   beforeEachBindings, | 
					
						
							|  |  |  |   SpyObject, | 
					
						
							|  |  |  | } from 'angular2/test_lib'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {MapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							|  |  |  | import {DOM} from 'angular2/src/dom/dom_adapter'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  | import {DomTestbed, TestRootView, elRef} from './dom_testbed'; | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   ViewDefinition, | 
					
						
							| 
									
										
										
										
											2015-08-14 10:03:45 -07:00
										 |  |  |   RenderDirectiveMetadata, | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |   RenderViewRef, | 
					
						
							|  |  |  |   ViewEncapsulation | 
					
						
							|  |  |  | } from 'angular2/src/render/api'; | 
					
						
							|  |  |  | import {DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES} from 'angular2/src/render/dom/dom_tokens'; | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  | import {bind} from 'angular2/di'; | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('DomRenderer integration', () => { | 
					
						
							|  |  |  |     beforeEachBindings(() => [DomTestbed]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should create and destroy root host views while using the given elements in place', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |          tb.compiler.compileHost(someComponent) | 
					
						
							|  |  |  |              .then((hostProtoViewDto) => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                var view = new TestRootView( | 
					
						
							|  |  |  |                    tb.renderer.createRootHostView(hostProtoViewDto.render, 0, '#root')); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |                expect(tb.rootEl.parentNode).toBeTruthy(); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                expect(view.hostElement).toEqual(tb.rootEl); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                tb.renderer.detachFragment(view.fragments[0]); | 
					
						
							|  |  |  |                tb.renderer.destroyView(view.viewRef); | 
					
						
							|  |  |  |                expect(tb.rootEl.parentNode).toBeFalsy(); | 
					
						
							| 
									
										
										
										
											2015-06-10 15:54:10 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |     it('should update text nodes', | 
					
						
							|  |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |          tb.compileAndMerge( | 
					
						
							|  |  |  |                someComponent, | 
					
						
							|  |  |  |                [ | 
					
						
							|  |  |  |                  new ViewDefinition( | 
					
						
							|  |  |  |                      {componentId: 'someComponent', template: '{{a}}', directives: []}) | 
					
						
							|  |  |  |                ]) | 
					
						
							|  |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                tb.renderer.setText(rootView.viewRef, 0, 'hello'); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText('hello'); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should update any element property/attributes/class/style independent of the compilation on the root element and other elements', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |          tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                             [ | 
					
						
							|  |  |  |                               new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '<input [title]="y" style="position:absolute">', | 
					
						
							|  |  |  |                                 directives: [] | 
					
						
							|  |  |  |                               }) | 
					
						
							|  |  |  |                             ]) | 
					
						
							|  |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  |                var checkSetters = (elr, el) => { | 
					
						
							|  |  |  |                  tb.renderer.setElementProperty(elr, 'tabIndex', 1); | 
					
						
							|  |  |  |                  expect((<HTMLInputElement>el).tabIndex).toEqual(1); | 
					
						
							| 
									
										
										
										
											2015-06-18 15:44:44 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  |                  tb.renderer.setElementClass(elr, 'a', true); | 
					
						
							|  |  |  |                  expect(DOM.hasClass(el, 'a')).toBe(true); | 
					
						
							|  |  |  |                  tb.renderer.setElementClass(elr, 'a', false); | 
					
						
							|  |  |  |                  expect(DOM.hasClass(el, 'a')).toBe(false); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  |                  tb.renderer.setElementStyle(elr, 'width', '10px'); | 
					
						
							|  |  |  |                  expect(DOM.getStyle(el, 'width')).toEqual('10px'); | 
					
						
							|  |  |  |                  tb.renderer.setElementStyle(elr, 'width', null); | 
					
						
							|  |  |  |                  expect(DOM.getStyle(el, 'width')).toEqual(''); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  |                  tb.renderer.setElementAttribute(elr, 'someAttr', 'someValue'); | 
					
						
							|  |  |  |                  expect(DOM.getAttribute(el, 'some-attr')).toEqual('someValue'); | 
					
						
							|  |  |  |                }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-07-16 08:27:59 -07:00
										 |  |  |                // root element
 | 
					
						
							|  |  |  |                checkSetters(elRef(rootView.viewRef, 0), rootView.hostElement); | 
					
						
							|  |  |  |                // nested elements
 | 
					
						
							|  |  |  |                checkSetters(elRef(rootView.viewRef, 1), DOM.firstChild(rootView.hostElement)); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('should NOT reflect property values as attributes if flag is NOT set', | 
					
						
							|  |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb) => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |          tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                             [ | 
					
						
							|  |  |  |                               new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '<input [title]="y">', | 
					
						
							|  |  |  |                                 directives: [] | 
					
						
							|  |  |  |                               }) | 
					
						
							|  |  |  |                             ]) | 
					
						
							|  |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                var el = DOM.childNodes(rootView.hostElement)[0]; | 
					
						
							|  |  |  |                tb.renderer.setElementProperty(elRef(rootView.viewRef, 1), 'maxLength', '20'); | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  |                expect(DOM.getAttribute(<HTMLInputElement>el, 'ng-reflect-max-length')) | 
					
						
							|  |  |  |                    .toEqual(null); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     describe('reflection', () => { | 
					
						
							|  |  |  |       beforeEachBindings(() => [bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(true)]); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  |       it('should reflect property values as attributes if flag is set', | 
					
						
							|  |  |  |          inject([AsyncTestCompleter, DomTestbed], (async, tb) => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |            tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                               [ | 
					
						
							|  |  |  |                                 new ViewDefinition({ | 
					
						
							|  |  |  |                                   componentId: 'someComponent', | 
					
						
							|  |  |  |                                   template: '<input [title]="y">', | 
					
						
							|  |  |  |                                   directives: [] | 
					
						
							|  |  |  |                                 }) | 
					
						
							|  |  |  |                               ]) | 
					
						
							|  |  |  |                .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                  var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                  var el = DOM.childNodes(rootView.hostElement)[0]; | 
					
						
							|  |  |  |                  tb.renderer.setElementProperty(elRef(rootView.viewRef, 1), 'maxLength', '20'); | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  |                  expect(DOM.getAttribute(<HTMLInputElement>el, 'ng-reflect-max-length')) | 
					
						
							|  |  |  |                      .toEqual('20'); | 
					
						
							|  |  |  |                  async.done(); | 
					
						
							|  |  |  |                }); | 
					
						
							|  |  |  |          })); | 
					
						
							| 
									
										
										
										
											2015-07-24 12:10:46 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       it('should reflect non-string property values as attributes if flag is set', | 
					
						
							|  |  |  |          inject([AsyncTestCompleter, DomTestbed], (async, tb) => { | 
					
						
							|  |  |  |            tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                               [ | 
					
						
							|  |  |  |                                 new ViewDefinition({ | 
					
						
							|  |  |  |                                   componentId: 'someComponent', | 
					
						
							|  |  |  |                                   template: '<input [title]="y">', | 
					
						
							|  |  |  |                                   directives: [] | 
					
						
							|  |  |  |                                 }) | 
					
						
							|  |  |  |                               ]) | 
					
						
							|  |  |  |                .then((protoViewMergeMappings) => { | 
					
						
							|  |  |  |                  var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							|  |  |  |                  var el = DOM.childNodes(rootView.hostElement)[0]; | 
					
						
							|  |  |  |                  tb.renderer.setElementProperty(elRef(rootView.viewRef, 1), 'maxLength', 20); | 
					
						
							|  |  |  |                  expect(DOM.getAttribute(<HTMLInputElement>el, 'ng-reflect-max-length')) | 
					
						
							|  |  |  |                      .toEqual('20'); | 
					
						
							|  |  |  |                  async.done(); | 
					
						
							|  |  |  |                }); | 
					
						
							|  |  |  |          })); | 
					
						
							| 
									
										
										
										
											2015-07-15 10:55:44 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-18 15:44:44 -07:00
										 |  |  |     if (DOM.supportsDOMEvents()) { | 
					
						
							|  |  |  |       it('should call actions on the element independent of the compilation', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |          inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |            tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                               [ | 
					
						
							|  |  |  |                                 new ViewDefinition({ | 
					
						
							|  |  |  |                                   componentId: 'someComponent', | 
					
						
							|  |  |  |                                   template: '<input [title]="y"></input>', | 
					
						
							|  |  |  |                                   directives: [] | 
					
						
							|  |  |  |                                 }) | 
					
						
							|  |  |  |                               ]) | 
					
						
							|  |  |  |                .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                  var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                  tb.renderer.invokeElementMethod(elRef(rootView.viewRef, 1), 'setAttribute', | 
					
						
							| 
									
										
										
										
											2015-06-18 15:44:44 -07:00
										 |  |  |                                                  ['a', 'b']); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                  expect(DOM.getAttribute(DOM.childNodes(rootView.hostElement)[0], 'a')) | 
					
						
							|  |  |  |                      .toEqual('b'); | 
					
						
							| 
									
										
										
										
											2015-06-18 15:44:44 -07:00
										 |  |  |                  async.done(); | 
					
						
							|  |  |  |                }); | 
					
						
							|  |  |  |          })); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |     it('should add and remove fragments', | 
					
						
							|  |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |          tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                             [ | 
					
						
							|  |  |  |                               new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '<template>hello</template>', | 
					
						
							|  |  |  |                                 directives: [] | 
					
						
							|  |  |  |                               }) | 
					
						
							|  |  |  |                             ]) | 
					
						
							|  |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                var elr = elRef(rootView.viewRef, 1); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText(''); | 
					
						
							|  |  |  |                var fragment = rootView.fragments[1]; | 
					
						
							|  |  |  |                tb.renderer.attachFragmentAfterElement(elr, fragment); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText('hello'); | 
					
						
							|  |  |  |                tb.renderer.detachFragment(fragment); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText(''); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 15:18:02 -07:00
										 |  |  |     it('should add and remove empty fragments', | 
					
						
							|  |  |  |        inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |          tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                             [ | 
					
						
							|  |  |  |                               new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '<template></template><template></template>', | 
					
						
							|  |  |  |                                 directives: [] | 
					
						
							|  |  |  |                               }) | 
					
						
							|  |  |  |                             ]) | 
					
						
							|  |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-07-16 15:18:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |                var elr = elRef(rootView.viewRef, 1); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText(''); | 
					
						
							|  |  |  |                var fragment = rootView.fragments[1]; | 
					
						
							|  |  |  |                var fragment2 = rootView.fragments[2]; | 
					
						
							|  |  |  |                tb.renderer.attachFragmentAfterElement(elr, fragment); | 
					
						
							|  |  |  |                tb.renderer.attachFragmentAfterFragment(fragment, fragment2); | 
					
						
							|  |  |  |                tb.renderer.detachFragment(fragment); | 
					
						
							|  |  |  |                tb.renderer.detachFragment(fragment2); | 
					
						
							|  |  |  |                expect(rootView.hostElement).toHaveText(''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |     it('should handle events', inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |          tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                             [ | 
					
						
							|  |  |  |                               new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '<input (change)="doSomething()">', | 
					
						
							|  |  |  |                                 directives: [] | 
					
						
							|  |  |  |                               }) | 
					
						
							|  |  |  |                             ]) | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |              .then((protoViewMergeMappings) => { | 
					
						
							|  |  |  |                var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                tb.triggerEvent(elRef(rootView.viewRef, 1), 'change'); | 
					
						
							|  |  |  |                var eventEntry = rootView.events[0]; | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |                // bound element index
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                expect(eventEntry[0]).toEqual(1); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |                // event type
 | 
					
						
							|  |  |  |                expect(eventEntry[1]).toEqual('change'); | 
					
						
							|  |  |  |                // actual event
 | 
					
						
							| 
									
										
										
										
											2015-06-17 16:21:40 -07:00
										 |  |  |                expect((<Map<any, any>>eventEntry[2]).get('$event').type).toEqual('change'); | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |     if (DOM.supportsNativeShadowDOM()) { | 
					
						
							|  |  |  |       describe('native shadow dom support', () => { | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |         it('should put the template into a shadow root', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |            inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  |              tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                                 [ | 
					
						
							|  |  |  |                                   new ViewDefinition({ | 
					
						
							|  |  |  |                                     componentId: 'someComponent', | 
					
						
							|  |  |  |                                     template: 'hello', | 
					
						
							|  |  |  |                                     directives: [], | 
					
						
							|  |  |  |                                     encapsulation: ViewEncapsulation.NATIVE | 
					
						
							|  |  |  |                                   }) | 
					
						
							|  |  |  |                                 ]) | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                  .then((protoViewMergeMappings) => { | 
					
						
							| 
									
										
										
										
											2015-07-20 09:59:44 -07:00
										 |  |  |                    var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |                    expect(DOM.getShadowRoot(rootView.hostElement)).toHaveText('hello'); | 
					
						
							|  |  |  |                    async.done(); | 
					
						
							|  |  |  |                  }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |            })); | 
					
						
							| 
									
										
										
										
											2015-07-24 15:28:44 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         it('should add styles from non native components to shadow roots while the view is not destroyed', | 
					
						
							|  |  |  |            inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => { | 
					
						
							|  |  |  |              tb.compileAndMerge(someComponent, | 
					
						
							|  |  |  |                                 [ | 
					
						
							|  |  |  |                                   new ViewDefinition({ | 
					
						
							|  |  |  |                                     componentId: 'someComponent', | 
					
						
							|  |  |  |                                     template: '', | 
					
						
							|  |  |  |                                     directives: [], | 
					
						
							|  |  |  |                                     encapsulation: ViewEncapsulation.NATIVE, | 
					
						
							|  |  |  |                                     styles: ['a {};'] | 
					
						
							|  |  |  |                                   }) | 
					
						
							|  |  |  |                                 ]) | 
					
						
							|  |  |  |                  .then((protoViewMergeMappings) => { | 
					
						
							|  |  |  |                    var rootView = tb.createView(protoViewMergeMappings); | 
					
						
							|  |  |  |                    tb.compiler.compile(new ViewDefinition({ | 
					
						
							|  |  |  |                                 componentId: 'someComponent', | 
					
						
							|  |  |  |                                 template: '', | 
					
						
							|  |  |  |                                 directives: [], | 
					
						
							|  |  |  |                                 encapsulation: ViewEncapsulation.NONE, | 
					
						
							|  |  |  |                                 styles: ['b {};'] | 
					
						
							|  |  |  |                               })) | 
					
						
							|  |  |  |                        .then(_ => { | 
					
						
							|  |  |  |                          expect(DOM.getShadowRoot(rootView.hostElement)).toHaveText('a {};b {};'); | 
					
						
							|  |  |  |                          tb.renderer.destroyView(rootView.viewRef); | 
					
						
							|  |  |  |                          tb.compiler.compile(new ViewDefinition({ | 
					
						
							|  |  |  |                                       componentId: 'someComponent', | 
					
						
							|  |  |  |                                       template: '', | 
					
						
							|  |  |  |                                       directives: [], | 
					
						
							|  |  |  |                                       encapsulation: ViewEncapsulation.NONE, | 
					
						
							|  |  |  |                                       styles: ['c {};'] | 
					
						
							|  |  |  |                                     })) | 
					
						
							|  |  |  |                              .then(_ => { | 
					
						
							|  |  |  |                                expect(DOM.getShadowRoot(rootView.hostElement)) | 
					
						
							|  |  |  |                                    .toHaveText('a {};b {};'); | 
					
						
							|  |  |  |                                async.done(); | 
					
						
							|  |  |  |                              }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                        }); | 
					
						
							|  |  |  |                  }); | 
					
						
							|  |  |  |            })); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:46:39 -07:00
										 |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-26 09:25:39 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-14 10:03:45 -07:00
										 |  |  | export var someComponent = RenderDirectiveMetadata.create( | 
					
						
							|  |  |  |     {id: 'someComponent', type: RenderDirectiveMetadata.COMPONENT_TYPE, selector: 'some-comp'}); |