2015-03-13 06:10:11 -04:00
|
|
|
import {
|
|
|
|
AsyncTestCompleter,
|
|
|
|
beforeEach,
|
|
|
|
ddescribe,
|
|
|
|
describe,
|
|
|
|
el,
|
|
|
|
expect,
|
|
|
|
iit,
|
|
|
|
inject,
|
|
|
|
it,
|
|
|
|
xit,
|
|
|
|
} from 'angular2/test_lib';
|
2015-02-27 17:50:06 -05:00
|
|
|
import {DOM} from 'angular2/src/dom/dom_adapter';
|
2015-02-24 10:05:45 -05:00
|
|
|
|
2015-02-05 16:08:05 -05:00
|
|
|
import {Decorator, Component} from 'angular2/src/core/annotations/annotations';
|
2015-04-09 15:20:11 -04:00
|
|
|
import {View} from 'angular2/src/core/annotations/view';
|
2015-02-24 10:05:45 -05:00
|
|
|
|
2015-04-07 23:54:20 -04:00
|
|
|
import {NgElement} from 'angular2/src/core/compiler/ng_element';
|
2015-03-30 11:11:18 -04:00
|
|
|
|
2015-02-04 16:27:31 -05:00
|
|
|
import {NonBindable} from 'angular2/src/directives/non_bindable';
|
2015-03-30 11:11:18 -04:00
|
|
|
|
|
|
|
import {TestBed} from 'angular2/src/test_lib/test_bed';
|
2015-01-08 07:57:41 -05:00
|
|
|
|
|
|
|
export function main() {
|
2015-02-04 16:27:31 -05:00
|
|
|
describe('non-bindable', () => {
|
2015-03-30 11:11:18 -04:00
|
|
|
it('should not interpolate children', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
2015-02-04 16:27:31 -05:00
|
|
|
var template = '<div>{{text}}<span non-bindable>{{text}}</span></div>';
|
2015-03-30 11:11:18 -04:00
|
|
|
tb.createView(TestComponent, {html: template}).then((view) => {
|
|
|
|
view.detectChanges();
|
2015-04-07 23:54:20 -04:00
|
|
|
expect(DOM.getText(view.rootNodes[0])).toEqual('foo{{text}}');
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-01-08 07:57:41 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-01-08 07:57:41 -05:00
|
|
|
|
2015-03-30 11:11:18 -04:00
|
|
|
it('should ignore directives on child nodes', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
2015-02-04 16:27:31 -05:00
|
|
|
var template = '<div non-bindable><span id=child test-dec>{{text}}</span></div>';
|
2015-03-30 11:11:18 -04:00
|
|
|
tb.createView(TestComponent, {html: template}).then((view) => {
|
|
|
|
view.detectChanges();
|
2015-04-07 23:54:20 -04:00
|
|
|
var span = DOM.querySelector(view.rootNodes[0], '#child');
|
2015-01-08 07:57:41 -05:00
|
|
|
expect(DOM.hasClass(span, 'compiled')).toBeFalsy();
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-01-08 07:57:41 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-01-08 07:57:41 -05:00
|
|
|
|
2015-03-30 11:11:18 -04:00
|
|
|
it('should trigger directives on the same node', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
2015-02-04 16:27:31 -05:00
|
|
|
var template = '<div><span id=child non-bindable test-dec>{{text}}</span></div>';
|
2015-03-30 11:11:18 -04:00
|
|
|
tb.createView(TestComponent, {html: template}).then((view) => {
|
|
|
|
view.detectChanges();
|
2015-04-07 23:54:20 -04:00
|
|
|
var span = DOM.querySelector(view.rootNodes[0], '#child');
|
2015-01-08 07:57:41 -05:00
|
|
|
expect(DOM.hasClass(span, 'compiled')).toBeTruthy();
|
2015-03-13 06:10:11 -04:00
|
|
|
async.done();
|
2015-01-08 07:57:41 -05:00
|
|
|
});
|
2015-03-13 06:10:11 -04:00
|
|
|
}));
|
2015-01-08 07:57:41 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-02-12 08:44:59 -05:00
|
|
|
@Component({selector: 'test-cmp'})
|
2015-04-09 15:20:11 -04:00
|
|
|
@View({directives: [NonBindable, TestDecorator]})
|
2015-01-08 07:57:41 -05:00
|
|
|
class TestComponent {
|
|
|
|
text: string;
|
|
|
|
constructor() {
|
|
|
|
this.text = 'foo';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Decorator({
|
|
|
|
selector: '[test-dec]'
|
|
|
|
})
|
|
|
|
class TestDecorator {
|
|
|
|
constructor(el: NgElement) {
|
|
|
|
DOM.addClass(el.domElement, 'compiled');
|
|
|
|
}
|
|
|
|
}
|