// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2010 Apple Inc. and contributors. // License: Licensed under MIT license (see license.js) // ========================================================================== /*global module test equals context ok same notest */ var source, indexes, observer, obj ; // base array to work with module("SC.RangeObserver#destroy", { setup: function() { // create array with 5 SC.Object's in them source = [1,2,3,4,5].map(function(x) { return SC.Object.create({ item: x, foo: "bar" }) ; }, this); indexes = SC.IndexSet.create(2,2); // select 2..3 observer = SC.Object.create({ callCount: 0, rangeDidChange: function() { this.callCount++; } }); obj = SC.RangeObserver.create(source, indexes, observer, observer.rangeDidChange, "context", YES); } }); test("returns receiver", function() { // for some reason doing equals() causes a stack exception (probably due // to a bug in jsDump) ok(obj.destroy() === obj, 'should return receiver'); }); // .......................................................... // OBSERVING // // NOTE: Since we are lazy about observing changes, we want to test both what // happens if you destroy the observer before any changes have happend and // after changes have happened. test("never observes changes if no changes happend", function() { obj.destroy(); // change property on each object var len = source.length, idx; for(idx=0;idx