Sha256: 61e2b1033e707d26f0269730f797a9c3e3e4abedb2ccadf7fbeca9e611bba677

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 KB

Contents

// ==========================================================================
// Project:   SproutCore Costello - Property Observing Library
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2010 Apple Inc. All rights reserved.
// License:   Licensed 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

7 entries across 7 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.4.5 lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js
sproutcore-1.4.5-java lib/frameworks/sproutcore/frameworks/runtime/tests/private/observer_queue/isObservingSuspended.js