Skip to content
Browse files

Added a test case demonstrating a problem with adding and replacing s…

…imultaneously
  • Loading branch information...
1 parent c547135 commit f46d17584474ed161ff6a56f55a891adbfb428fd @hufman committed Apr 11, 2012
Showing with 55 additions and 0 deletions.
  1. +55 −0 packages/ember-handlebars/tests/each_test.js
View
55 packages/ember-handlebars/tests/each_test.js
@@ -70,6 +70,61 @@ test("it updates the view if an item is removed", function() {
assertHTML(view, "Annabelle");
});
+test("it updates the view if an item is replaced", function() {
+ Ember.run(function() {
+ people.removeAt(0);
+ people.insertAt(0, { name: "Kazuki" });
+ });
+
+ assertHTML(view, "KazukiAnnabelle");
+});
+
+test("can add and replace in the same runloop", function() {
+ Ember.run(function() {
+ people.pushObject({ name: "Tom Dale" });
+ people.removeAt(0);
+ people.insertAt(0, { name: "Kazuki" });
+ });
+
+ assertHTML(view, "KazukiAnnabelleTom Dale");
+});
+
+test("can add and replace the object before the add in the same runloop", function() {
+ Ember.run(function() {
+ people.pushObject({ name: "Tom Dale" });
+ people.removeAt(1);
+ people.insertAt(1, { name: "Kazuki" });
+ });
+
+ assertHTML(view, "Steve HoltKazukiTom Dale");
+});
+
+test("can add and replace complicatedly", function() {
+ Ember.run(function() {
+ people.pushObject({ name: "Tom Dale" });
+ people.removeAt(1);
+ people.insertAt(1, { name: "Kazuki" });
+ people.pushObject({ name: "Firestone" });
+ people.pushObject({ name: "McMunch" });
+ people.removeAt(3);
+ });
+
+ assertHTML(view, "Steve HoltKazukiTom DaleMcMunch");
+});
+
+test("can add and replace complicatedly harder", function() {
+ Ember.run(function() {
+ people.pushObject({ name: "Tom Dale" });
+ people.removeAt(1);
+ people.insertAt(1, { name: "Kazuki" });
+ people.pushObject({ name: "Firestone" });
+ people.pushObject({ name: "McMunch" });
+ people.removeAt(2);
+ });
+
+ assertHTML(view, "Steve HoltKazukiFirestoneMcMunch");
+});
+
module("the #each helper", {
setup: function() {
people = Ember.A([{ name: "Steve Holt" }, { name: "Annabelle" }]);

0 comments on commit f46d175

Please sign in to comment.
Something went wrong with that request. Please try again.