regression test for #724

This commit is contained in:
David Greenspan
2013-02-22 14:04:33 -08:00
parent a102deee80
commit 8a5db13f90
2 changed files with 56 additions and 0 deletions

View File

@@ -326,3 +326,23 @@
<template name="test_type_casting">
{{testTypeCasting 'true' 'false' true false 0 1 -1 10 -10 1asdf -1asdf}}
</template>
<!-- Test for issue #724 - template branches are labeled wrong -->
<template name="test_template_trickylabels_a0">
{{#unless loading}}
{{> test_template_trickylabels_a1}}
{{/unless}}
</template>
<template name="test_template_trickylabels_a1">
{{#isolate}}
{{> test_template_trickylabels_a2}}
{{v}}
{{/isolate}}
<div>bar</div>
</template>
<template name="test_template_trickylabels_a2">
<div>foo</div>
</template>

View File

@@ -1032,3 +1032,39 @@ Tinytest.add('templating - helper typecast Issue #617', function (test) {
"[object]");
});
Tinytest.add("templating - tricky branch labels", function (test) {
// regression test for issue #724
var loading = ReactiveVar(true);
var v = ReactiveVar(1);
var x = [];
Template.test_template_trickylabels_a0.loading = function () {
return loading.get();
};
Template.test_template_trickylabels_a1.v = function () {
return v.get();
};
_.extend(Template.test_template_trickylabels_a2, {
created: function () { x.push('c'); },
rendered: function () { x.push('r'); },
destroyed: function () { x.push('d'); }
});
var div = OnscreenDiv(Meteor.render(Template.test_template_trickylabels_a0));
Meteor.flush();
loading.set(false);
Meteor.flush();
x.length = 0;
v.set(2);
Meteor.flush();
test.equal(x.join(''), 'r'); // no 'c' or 'd'
test.equal(div.html().replace(/\s+/g, ''), '<div>foo</div>2<div>bar</div>');
div.kill();
Meteor.flush();
});