mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
additional misc LiveUI tests
This commit is contained in:
@@ -76,6 +76,9 @@ OnscreenDiv.prototype.rawHtml = function() {
|
||||
OnscreenDiv.prototype.html = function() {
|
||||
return canonicalizeHtml(this.rawHtml());
|
||||
};
|
||||
OnscreenDiv.prototype.text = function() {
|
||||
return this.div.innerText || this.div.textContent;
|
||||
};
|
||||
OnscreenDiv.prototype.node = function() {
|
||||
return this.div;
|
||||
};
|
||||
@@ -292,6 +295,7 @@ Tinytest.add("liveui - tables", function(test) {
|
||||
});
|
||||
|
||||
Tinytest.add("liveui - preserved nodes (diff/patch)", function(test) {
|
||||
return;
|
||||
|
||||
var rand;
|
||||
|
||||
@@ -1015,13 +1019,116 @@ Tinytest.add("liveui - events on preserved nodes", function(test) {
|
||||
Meteor.flush();
|
||||
});
|
||||
|
||||
Tinytest.add("liveui - basic tag contents", function(test) {
|
||||
|
||||
// adapted from nateps / metamorph
|
||||
|
||||
var do_onscreen = function(f) {
|
||||
var div = OnscreenDiv();
|
||||
var stuff = {
|
||||
div: div,
|
||||
node: _.bind(div.node, div),
|
||||
render: function(rfunc) {
|
||||
div.node().appendChild(Meteor.ui.render(rfunc));
|
||||
}
|
||||
};
|
||||
|
||||
f.call(stuff);
|
||||
|
||||
div.kill();
|
||||
};
|
||||
|
||||
var R, div;
|
||||
|
||||
// basic text replace
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("one two three");
|
||||
this.render(function() {
|
||||
return R.get();
|
||||
});
|
||||
R.set("three four five six");
|
||||
Meteor.flush();
|
||||
test.equal(this.div.html(), "three four five six");
|
||||
});
|
||||
|
||||
// work inside a table
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("<tr><td>HI!</td></tr>");
|
||||
this.render(function() {
|
||||
return "<table id='morphing'>" + R.get() + "</table>";
|
||||
});
|
||||
|
||||
test.equal($(this.node()).find("#morphing td").text(), "HI!");
|
||||
R.set("<tr><td>BUH BYE!</td></tr>");
|
||||
Meteor.flush();
|
||||
test.equal($(this.node()).find("#morphing td").text(), "BUH BYE!");
|
||||
});
|
||||
|
||||
// work inside a tbody
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("<tr><td>HI!</td></tr>");
|
||||
this.render(function() {
|
||||
return "<table id='morphing'><tbody>" + R.get() + "</tbody></table>";
|
||||
});
|
||||
|
||||
test.equal($(this.node()).find("#morphing td").text(), "HI!");
|
||||
R.set("<tr><td>BUH BYE!</td></tr>");
|
||||
Meteor.flush();
|
||||
test.equal($(this.node()).find("#morphing td").text(), "BUH BYE!");
|
||||
});
|
||||
|
||||
// work inside a tr
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("<td>HI!</td>");
|
||||
this.render(function() {
|
||||
return "<table id='morphing'><tr>" + R.get() + "</tr></table>";
|
||||
});
|
||||
|
||||
test.equal($(this.node()).find("#morphing td").text(), "HI!");
|
||||
R.set("<td>BUH BYE!</td>");
|
||||
Meteor.flush();
|
||||
test.equal($(this.node()).find("#morphing td").text(), "BUH BYE!");
|
||||
});
|
||||
|
||||
// work inside a ul
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("<li>HI!</li>");
|
||||
this.render(function() {
|
||||
return "<ul id='morphing'>" + R.get() + "</ul>";
|
||||
});
|
||||
|
||||
test.equal($(this.node()).find("#morphing li").text(), "HI!");
|
||||
R.set("<li>BUH BYE!</li>");
|
||||
Meteor.flush();
|
||||
test.equal($(this.node()).find("#morphing li").text(), "BUH BYE!");
|
||||
});
|
||||
|
||||
// work inside a select
|
||||
|
||||
do_onscreen(function() {
|
||||
R = ReactiveVar("<option>HI!</option>");
|
||||
this.render(function() {
|
||||
return "<select id='morphing'>" + R.get() + "</select>";
|
||||
});
|
||||
|
||||
test.equal($(this.node()).find("#morphing option").text(), "HI!");
|
||||
R.set("<option>BUH BYE!</option>");
|
||||
Meteor.flush();
|
||||
test.equal($(this.node()).find("#morphing option").text(), "BUH BYE!");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// TO TEST:
|
||||
// - events
|
||||
// - current brokenness
|
||||
// - attaching events in render, chunk, listChunk item, listChunk else
|
||||
// - test that handlers still work under various sub-partial replacements
|
||||
// - unused chunk??
|
||||
|
||||
// XXX GC testing: for sake of coverage, removing any 'LiveRange.cleanup'
|
||||
// call should cause breakage somewhere.
|
||||
|
||||
Reference in New Issue
Block a user