Fix a test of UI._templateInstance()

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.
This commit is contained in:
David Greenspan
2014-06-21 15:54:18 -07:00
parent 5dbd5218f3
commit e4d9d32a71

View File

@@ -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.