2016-04-12 12:40:37 -04:00
|
|
|
import {
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
2016-04-28 20:50:03 -04:00
|
|
|
} from '@angular/core/testing/testing_internal';
|
|
|
|
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
|
|
|
|
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
|
|
|
import {Component, Directive} from '@angular/core';
|
|
|
|
import {ElementRef} from '@angular/core/src/linker/element_ref';
|
|
|
|
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
2015-05-26 17:22:35 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
describe('non-bindable', () => {
|
2015-06-11 21:50:41 -04:00
|
|
|
it('should not interpolate children',
|
2016-06-09 14:04:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
2015-11-23 19:02:19 -05:00
|
|
|
var template = '<div>{{text}}<span ngNonBindable>{{text}}</span></div>';
|
2015-06-24 16:07:15 -04:00
|
|
|
tcb.overrideTemplate(TestComponent, template)
|
|
|
|
.createAsync(TestComponent)
|
2015-10-31 12:50:19 -04:00
|
|
|
.then((fixture) => {
|
|
|
|
fixture.detectChanges();
|
|
|
|
expect(fixture.debugElement.nativeElement).toHaveText('foo{{text}}');
|
2015-05-26 17:22:35 -04:00
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should ignore directives on child nodes',
|
2016-06-09 14:04:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
2015-11-23 19:02:19 -05:00
|
|
|
var template = '<div ngNonBindable><span id=child test-dec>{{text}}</span></div>';
|
2015-06-24 16:07:15 -04:00
|
|
|
tcb.overrideTemplate(TestComponent, template)
|
|
|
|
.createAsync(TestComponent)
|
2015-10-31 12:50:19 -04:00
|
|
|
.then((fixture) => {
|
|
|
|
fixture.detectChanges();
|
2015-06-24 16:07:15 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
// We must use getDOM().querySelector instead of fixture.query here
|
2015-06-24 16:07:15 -04:00
|
|
|
// since the elements inside are not compiled.
|
2016-04-28 20:50:03 -04:00
|
|
|
var span = getDOM().querySelector(fixture.debugElement.nativeElement, '#child');
|
|
|
|
expect(getDOM().hasClass(span, 'compiled')).toBeFalsy();
|
2015-05-26 17:22:35 -04:00
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should trigger directives on the same node',
|
2016-06-09 14:04:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
|
2015-11-23 19:02:19 -05:00
|
|
|
var template = '<div><span id=child ngNonBindable test-dec>{{text}}</span></div>';
|
2015-06-24 16:07:15 -04:00
|
|
|
tcb.overrideTemplate(TestComponent, template)
|
|
|
|
.createAsync(TestComponent)
|
2015-10-31 12:50:19 -04:00
|
|
|
.then((fixture) => {
|
|
|
|
fixture.detectChanges();
|
2016-04-28 20:50:03 -04:00
|
|
|
var span = getDOM().querySelector(fixture.debugElement.nativeElement, '#child');
|
|
|
|
expect(getDOM().hasClass(span, 'compiled')).toBeTruthy();
|
2015-05-26 17:22:35 -04:00
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@Directive({selector: '[test-dec]'})
|
|
|
|
class TestDirective {
|
2016-04-28 20:50:03 -04:00
|
|
|
constructor(el: ElementRef) { getDOM().addClass(el.nativeElement, 'compiled'); }
|
2015-05-26 17:22:35 -04:00
|
|
|
}
|
|
|
|
|
2016-03-08 16:36:48 -05:00
|
|
|
@Component({selector: 'test-cmp', directives: [TestDirective], template: ''})
|
2015-05-26 17:22:35 -04:00
|
|
|
class TestComponent {
|
|
|
|
text: string;
|
|
|
|
constructor() { this.text = 'foo'; }
|
|
|
|
}
|