Sha256: 6a14b2b3965765b00ab7d49d329e5b543ec5468d6efa694374343f7fc8079ef7

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            Portions ©2008-2009 Apple, Inc. All rights reserved.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

var callCount, obj;

module("SC.Observers.isObservingSuspended", {
  setup: function() {
    callCount = 0;
    
    obj = SC.Object.create({ 
      foo: "bar",

      fooDidChange: function() { 
        callCount++; 
      }.observes('foo')
    });
  }
});

test("suspending observers stops notification", function() {
  SC.Observers.suspendPropertyObserving();
  SC.Observers.suspendPropertyObserving();
  obj.set("foo");
  equals(callCount, 0, 'should not notify observer while suspended');

  SC.Observers.resumePropertyObserving();
  equals(callCount, 0, 'should not notify observer while still suspended');
  
  SC.Observers.resumePropertyObserving();
  equals(callCount, 1, 'should notify observer when resumed');
  
});

// ..........................................................
// SPECIAL CASES
// 

// this test verifies a specific bug in the SC.Observing.propertyDidChange method.
test("suspended notifications should work when nesting property change groups", function() {
  
  SC.Observers.suspendPropertyObserving();
  obj.beginPropertyChanges();
  obj.set("foo");
  equals(callCount, 0, 'should not notify observer while suspended');

  obj.endPropertyChanges();
  equals(callCount, 0, 'should not notify observer while suspended');

  SC.Observers.resumePropertyObserving();
  equals(callCount, 1, 'should notify observer when resumed');
});

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js