Add regression tests for d56d9da

Make sure inclusions with one path segment like “..” and “foo” (where foo is in the data context) don’t cause the enclosing template to re-render when the data context changes.
This commit is contained in:
David Greenspan
2014-07-16 15:06:13 -07:00
parent 31fc5b0887
commit 2e191e0b09
2 changed files with 56 additions and 0 deletions

View File

@@ -902,3 +902,23 @@ Hi there!
<template name="spacebars_test_event_cleanup_on_destroyed_inner">
<span>foo</span>
</template>
<template name="spacebars_test_isolated_lookup_inclusion">
x
</template>
<template name="spacebars_test_isolated_lookup1">
{{> foo}}--{{> spacebars_test_isolated_lookup_inclusion}}
</template>
<template name="spacebars_test_isolated_lookup2">
{{#with foo}}
{{#with z=1}}
{{> ..}}--{{> spacebars_test_isolated_lookup_inclusion}}
{{/with}}
{{/with}}
</template>
<template name="spacebars_test_isolated_lookup3">
{{> bar}}--{{> spacebars_test_isolated_lookup_inclusion}}
</template>

View File

@@ -2572,3 +2572,39 @@ Tinytest.add(
document.body.removeChild(div);
});
_.each([1, 2, 3], function (n) {
Tinytest.add(
"spacebars-tests - template_tests - lookup is isolated " + n,
function (test) {
var buf = "";
var inclusion = Template.spacebars_test_isolated_lookup_inclusion;
inclusion.created = function () { buf += 'C'; };
inclusion.destroyed = function () { buf += 'D'; };
var tmpl = Template['spacebars_test_isolated_lookup' + n];
var R = ReactiveVar(Template.spacebars_template_test_aaa);
tmpl.bar = function () {
return R.get();
};
var div = renderToDiv(
tmpl,
function () {
return { foo: R.get() };
});
test.equal(canonicalizeHtml(div.innerHTML), 'aaa--x');
test.equal(buf, 'C');
R.set(Template.spacebars_template_test_bbb);
Deps.flush();
test.equal(canonicalizeHtml(div.innerHTML), 'bbb--x');
test.equal(buf, 'C');
R.set(null);
Deps.flush({_throwFirstError:true});
test.equal(canonicalizeHtml(div.innerHTML), '--x');
test.equal(buf, 'C');
}
);
});