From e4d9d32a716f52ad9bafa44bdb91078efa2aad91 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Sat, 21 Jun 2014 15:54:18 -0700 Subject: [PATCH] Fix a test of UI._templateInstance() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This actually morphs the test into a different test. The old test wasn’t really valid; it checked that you could reach the rendered DOM of a helper from the templateInstance retrieved from the helper. It only worked before because templateInstance.firstNode was an empty text node marker, so when the helper returned “first”, it would in effect save a pointer to the empty text node before the position where “first” would appear. --- packages/spacebars-tests/template_tests.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/spacebars-tests/template_tests.js b/packages/spacebars-tests/template_tests.js index e095e8d84f..7f2da3c889 100644 --- a/packages/spacebars-tests/template_tests.js +++ b/packages/spacebars-tests/template_tests.js @@ -2078,19 +2078,16 @@ Tinytest.add( var instanceFromHelper; tmpl.foo = function () { - instanceFromHelper = UI._templateInstance(); - return rv.get(); + return UI._templateInstance().data; }; - var div = renderToDiv(tmpl); + var div = renderToDiv(tmpl, function () { return rv.get(); }); rv.set("first"); - Deps.flush(); - // `nextSibling` because the first node is an empty text node. - test.equal($(instanceFromHelper.firstNode.nextSibling).text(), "first"); + divRendersTo(test, div, "first"); rv.set("second"); Deps.flush(); - test.equal($(instanceFromHelper.firstNode.nextSibling).text(), "second"); + divRendersTo(test, div, "second"); // UI._templateInstance() should throw when called from not within a // helper.