Sha256: 4676dbdd9b08c1fe49f92080b852a2862b9cbd3d4ba80a01a038812ba3b30b14
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module("chained observers"); test("chained observers on enumerable properties are triggered when the observed property of any item changes", function() { var family = SC.Object.create({ momma: null }); var momma = SC.Object.create({ children: [] }); var child1 = SC.Object.create({ name: "Bartholomew" }); var child2 = SC.Object.create({ name: "Agnes" }); var child3 = SC.Object.create({ name: "Dan" }); var child4 = SC.Object.create({ name: "Nancy" }); family.set('momma', momma); momma.set('children', [child1, child2, child3]); var observerFiredCount = 0; family.addObserver('momma.children.@each.name', this, function() { observerFiredCount++; }); observerFiredCount = 0; SC.run(function() { child1.set('name', 'Teddy'); }); equals(observerFiredCount, 1, "observer fired after changing a child item's name"); observerFiredCount = 0; SC.run(function() { momma.children.pushObject(child4); }); equals(observerFiredCount, 1, "observer fired after adding a new item"); observerFiredCount = 0; SC.run(function() { child4.set('name', "Herbert"); }); equals(observerFiredCount, 1, "observer fired after changing property on new object"); momma.set('children', []); observerFiredCount = 0; SC.run(function() { child1.set('name', "Hanna"); }); equals(observerFiredCount, 0, "observer did not fire after removing changing property on a removed object"); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spade-0.0.1 | sproutcore/frameworks/runtime/tests/mixins/observable/chained.js |