| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |   TestComponentBuilder, | 
					
						
							|  |  |  |   By, | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |   beforeEach, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   xit, | 
					
						
							|  |  |  | } from 'angular2/test_lib'; | 
					
						
							|  |  |  | import {DOM} from 'angular2/src/dom/dom_adapter'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {Component, Directive, View} from 'angular2/angular2'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {ElementRef} from 'angular2/src/core/compiler/element_ref'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {NgNonBindable} from 'angular2/src/directives/ng_non_bindable'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function main() { | 
					
						
							|  |  |  |   describe('non-bindable', () => { | 
					
						
							| 
									
										
										
										
											2015-06-11 18:50:41 -07:00
										 |  |  |     it('should not interpolate children', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |        inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |          var template = '<div>{{text}}<span ng-non-bindable>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							|  |  |  |              .then((rootTC) => { | 
					
						
							|  |  |  |                rootTC.detectChanges(); | 
					
						
							|  |  |  |                expect(rootTC.nativeElement).toHaveText('foo{{text}}'); | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should ignore directives on child nodes', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |        inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |          var template = '<div ng-non-bindable><span id=child test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							|  |  |  |              .then((rootTC) => { | 
					
						
							|  |  |  |                rootTC.detectChanges(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                // We must use DOM.querySelector instead of rootTC.query here
 | 
					
						
							|  |  |  |                // since the elements inside are not compiled.
 | 
					
						
							|  |  |  |                var span = DOM.querySelector(rootTC.nativeElement, '#child'); | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |                expect(DOM.hasClass(span, 'compiled')).toBeFalsy(); | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should trigger directives on the same node', | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |        inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |          var template = '<div><span id=child ng-non-bindable test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							|  |  |  |              .then((rootTC) => { | 
					
						
							|  |  |  |                rootTC.detectChanges(); | 
					
						
							|  |  |  |                var span = DOM.querySelector(rootTC.nativeElement, '#child'); | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |                expect(DOM.hasClass(span, 'compiled')).toBeTruthy(); | 
					
						
							|  |  |  |                async.done(); | 
					
						
							|  |  |  |              }); | 
					
						
							|  |  |  |        })); | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Directive({selector: '[test-dec]'}) | 
					
						
							|  |  |  | class TestDirective { | 
					
						
							| 
									
										
										
										
											2015-06-23 14:26:02 -07:00
										 |  |  |   constructor(el: ElementRef) { DOM.addClass(el.nativeElement, 'compiled'); } | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({selector: 'test-cmp'}) | 
					
						
							|  |  |  | @View({directives: [NgNonBindable, TestDirective]}) | 
					
						
							|  |  |  | class TestComponent { | 
					
						
							|  |  |  |   text: string; | 
					
						
							|  |  |  |   constructor() { this.text = 'foo'; } | 
					
						
							|  |  |  | } |