fix(view): ViewPort light should come from the direct parent

This commit is contained in:
Victor Berchet
2015-02-10 18:37:47 +01:00
parent b953956a35
commit fc1b791a7a
4 changed files with 52 additions and 3 deletions
@@ -153,6 +153,26 @@ export function main() {
return shadow;
}
describe("ProtoElementInjector", () => {
describe("direct parent", () => {
it("should return parent proto injector when distance is 1", () => {
var distance = 1;
var protoParent = new ProtoElementInjector(null, 0, []);
var protoChild = new ProtoElementInjector(protoParent, 1, [], false, distance);
expect(protoChild.directParent()).toEqual(protoParent);
});
it("should return null otherwise", () => {
var distance = 2;
var protoParent = new ProtoElementInjector(null, 0, []);
var protoChild = new ProtoElementInjector(protoParent, 1, [], false, distance);
expect(protoChild.directParent()).toEqual(null);
});
});
});
describe("ElementInjector", function () {
describe("instantiate", function () {
it("should create an element injector", function () {
@@ -77,6 +77,31 @@ export function main() {
});
});
it("should redistribute direct child viewports when the light dom changes", (done) => {
var temp = '<multiple-content-tags>' +
'<div><div template="manual" class="left">A</div></div>' +
'<div>B</div>' +
'</multiple-content-tags>';
compile(temp, (view, lc) => {
var dir = view.elementInjectors[1].get(ManualTemplateDirective);
expect(view.nodes).toHaveText('(, B)');
dir.show();
lc.tick();
expect(view.nodes).toHaveText('(, AB)');
dir.hide();
lc.tick();
expect(view.nodes).toHaveText('(, B)');
done();
});
});
it("should redistribute when the light dom changes", (done) => {
var temp = '<multiple-content-tags>' +
'<div template="manual" class="left">A</div>' +