2015-05-26 17:22:35 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
2015-06-24 16:07:15 -04:00
|
|
|
TestComponentBuilder,
|
2015-05-26 17:22:35 -04:00
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
el,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
2015-10-13 03:29:13 -04:00
|
|
|
} from 'angular2/testing_internal';
|
2015-11-19 18:09:34 -05:00
|
|
|
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
2016-03-08 16:36:48 -05:00
|
|
|
import {Component, Directive} from 'angular2/core';
|
2015-10-02 10:37:23 -04:00
|
|
|
import {ElementRef} from 'angular2/src/core/linker/element_ref';
|
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',
|
2015-06-24 16:07:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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',
|
2015-06-24 16:07:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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
|
|
|
|
2015-10-31 12:50:19 -04:00
|
|
|
// We must use DOM.querySelector instead of fixture.query here
|
2015-06-24 16:07:15 -04:00
|
|
|
// since the elements inside are not compiled.
|
2015-10-31 12:50:19 -04:00
|
|
|
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
|
2015-05-26 17:22:35 -04:00
|
|
|
expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
it('should trigger directives on the same node',
|
2015-06-24 16:07:15 -04:00
|
|
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
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();
|
|
|
|
var span = DOM.querySelector(fixture.debugElement.nativeElement, '#child');
|
2015-05-26 17:22:35 -04:00
|
|
|
expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
|
|
|
|
async.done();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
@Directive({selector: '[test-dec]'})
|
|
|
|
class TestDirective {
|
2015-06-23 17:26:02 -04:00
|
|
|
constructor(el: ElementRef) { DOM.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'; }
|
|
|
|
}
|