From b809f4086753ad3c07cf047fb0c27ba9ce817028 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 2 Jul 2012 21:17:29 -0700 Subject: [PATCH] chunk matching test that fails --- packages/liveui/liveui.js | 2 + packages/liveui/liveui_tests.js | 81 +++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/packages/liveui/liveui.js b/packages/liveui/liveui.js index 0f6710264e..7e38e632a8 100644 --- a/packages/liveui/liveui.js +++ b/packages/liveui/liveui.js @@ -313,6 +313,8 @@ Meteor.ui = Meteor.ui || {}; callOffscreen(); }; + range.branch = options.branch; + cx.on_invalidate(function() { if (range.context === cx) // make sure not an old cx range.update(); diff --git a/packages/liveui/liveui_tests.js b/packages/liveui/liveui_tests.js index 445ebe83bf..a43a95d031 100644 --- a/packages/liveui/liveui_tests.js +++ b/packages/liveui/liveui_tests.js @@ -2074,4 +2074,85 @@ Tinytest.add("liveui - controls", function(test) { div.kill(); }); +Tinytest.add("liveui - chunk matching", function(test) { + + // basic created / onscreen / offscreen callback flow + + var buf; + var counts; + + var testCallbacks = function(theNum /*, extend opts*/) { + return _.extend.apply(_, [{ + created: function() { + this.num = String(theNum); + var howManyBefore = counts[this.num] || 0; + counts[this.num] = howManyBefore + 1; + for(var i=0;i"+Meteor.ui.chunk(function() { + return "HI"; + }, testCallbacks(1, {branch: "foo"}))+""; + }, testCallbacks(0))); + + test.equal(buf, []); + Meteor.flush(); + // what order of chunks {0,1} is preferable?? + // should be consistent but I'm not sure what makes most sense. + test.equal(buf, "c1,on1,c0,on0".split(',')); + buf.length = 0; + + R.set("B"); + Meteor.flush(); + test.equal(buf, "on1,on0".split(',')); + buf.length = 0; + + div.kill(); + Meteor.flush(); + buf.sort(); + test.equal(buf, "off0,off1".split(',')); +}); + + })();