From af9bc84eccd67b33e6bfb49f4b664ff9d2f55a84 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Tue, 18 Mar 2014 14:32:07 -0700 Subject: [PATCH] Test for helper re-run after template removed (some failures) --- packages/spacebars-tests/template_tests.html | 44 ++++++++++++++++++ packages/spacebars-tests/template_tests.js | 49 ++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/packages/spacebars-tests/template_tests.html b/packages/spacebars-tests/template_tests.html index 96a581c52f..3d9b4a0e17 100644 --- a/packages/spacebars-tests/template_tests.html +++ b/packages/spacebars-tests/template_tests.html @@ -530,3 +530,47 @@ Hi there! {{#foo}} {{/foo}} + + + + + + + + + + + + + + diff --git a/packages/spacebars-tests/template_tests.js b/packages/spacebars-tests/template_tests.js index 65bd26df40..4d9574c55c 100644 --- a/packages/spacebars-tests/template_tests.js +++ b/packages/spacebars-tests/template_tests.js @@ -1656,3 +1656,52 @@ Tinytest.add('spacebars - template - custom block helper functions called exactl Deps.flush(); test.equal(count, 2); }); + +var runOneTwoTest = function (test, subTemplateName) { + var tmpl = Template.spacebars_test_helpers_stop_onetwo; + tmpl.one = Template[subTemplateName + '1']; + tmpl.two = Template[subTemplateName + '2']; + + var buf = ''; + + var showOne = ReactiveVar(true); + var dummy = ReactiveVar(1); + + tmpl.showOne = function () { return showOne.get(); }; + tmpl.one.options = function () { + dummy.get(); + buf += '1'; + return ['something']; + }; + tmpl.two.options = function () { + dummy.get(); + buf += '2'; + return ['something']; + }; + + var div = renderToDiv(tmpl); + divRendersTo(test, div, "one"); + test.equal(buf, '1'); + + showOne.set(false); + dummy.set(2); + divRendersTo(test, div, "two"); + test.equal(buf, '12'); + + showOne.set(true); + dummy.set(3); + divRendersTo(test, div, "one"); + test.equal(buf, '121'); +}; + +Tinytest.add('spacebars - template - with stops without re-running helper', function (test) { + runOneTwoTest(test, 'spacebars_test_helpers_stop_with'); +}); + +Tinytest.add('spacebars - template - each stops without re-running helper', function (test) { + runOneTwoTest(test, 'spacebars_test_helpers_stop_each'); +}); + +Tinytest.add('spacebars - template - if stops without re-running helper', function (test) { + runOneTwoTest(test, 'spacebars_test_helpers_stop_if'); +});