| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  | import { | 
					
						
							|  |  |  |   AsyncTestCompleter, | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |   TestComponentBuilder, | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  |   beforeEach, | 
					
						
							|  |  |  |   ddescribe, | 
					
						
							|  |  |  |   describe, | 
					
						
							|  |  |  |   el, | 
					
						
							|  |  |  |   expect, | 
					
						
							|  |  |  |   iit, | 
					
						
							|  |  |  |   inject, | 
					
						
							|  |  |  |   it, | 
					
						
							|  |  |  |   xit, | 
					
						
							| 
									
										
										
										
											2015-10-13 00:29:13 -07:00
										 |  |  | } from 'angular2/testing_internal'; | 
					
						
							| 
									
										
										
										
											2015-11-19 15:09:34 -08:00
										 |  |  | import {DOM} from 'angular2/src/platform/dom/dom_adapter'; | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | import {Component, Directive, View} from 'angular2/core'; | 
					
						
							| 
									
										
										
										
											2015-10-02 07:37:23 -07:00
										 |  |  | import {ElementRef} from 'angular2/src/core/linker/element_ref'; | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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-11-23 16:02:19 -08:00
										 |  |  |          var template = '<div>{{text}}<span ngNonBindable>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							| 
									
										
										
										
											2015-10-31 09:50:19 -07:00
										 |  |  |              .then((fixture) => { | 
					
						
							|  |  |  |                fixture.detectChanges(); | 
					
						
							|  |  |  |                expect(fixture.debugElement.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-11-23 16:02:19 -08:00
										 |  |  |          var template = '<div ngNonBindable><span id=child test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							| 
									
										
										
										
											2015-10-31 09:50:19 -07:00
										 |  |  |              .then((fixture) => { | 
					
						
							|  |  |  |                fixture.detectChanges(); | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-31 09:50:19 -07:00
										 |  |  |                // We must use DOM.querySelector instead of fixture.query here
 | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |                // since the elements inside are not compiled.
 | 
					
						
							| 
									
										
										
										
											2015-10-31 09:50:19 -07:00
										 |  |  |                var span = DOM.querySelector(fixture.debugElement.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-11-23 16:02:19 -08:00
										 |  |  |          var template = '<div><span id=child ngNonBindable test-dec>{{text}}</span></div>'; | 
					
						
							| 
									
										
										
										
											2015-06-24 13:07:15 -07:00
										 |  |  |          tcb.overrideTemplate(TestComponent, template) | 
					
						
							|  |  |  |              .createAsync(TestComponent) | 
					
						
							| 
									
										
										
										
											2015-10-31 09:50:19 -07:00
										 |  |  |              .then((fixture) => { | 
					
						
							|  |  |  |                fixture.detectChanges(); | 
					
						
							|  |  |  |                var span = DOM.querySelector(fixture.debugElement.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'}) | 
					
						
							| 
									
										
										
										
											2015-10-01 10:07:49 -07:00
										 |  |  | @View({directives: [TestDirective]}) | 
					
						
							| 
									
										
										
										
											2015-05-26 14:22:35 -07:00
										 |  |  | class TestComponent { | 
					
						
							|  |  |  |   text: string; | 
					
						
							|  |  |  |   constructor() { this.text = 'foo'; } | 
					
						
							|  |  |  | } |