Sha256: 394bf2fd0006c1b5090f3f708c7b6f2d5f46758eb91185c62c9922c08a00bcb6

Contents?: true

Size: 1.63 KB

Versions: 30

Compression:

Stored size: 1.63 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            ©2008-2011 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
var view, contentA, contentB;

module('ContentDisplay', {
  setup: function() {
    contentA = SC.Object.create({
      foo: 'foo.A',
      bar: 'bar.A'
    });

    contentB = SC.Object.create({
      foo: 'foo.B',
      bar: 'bar.B'
    });

    view = SC.View.create(SC.ContentDisplay, {
      contentDisplayProperties: ['foo', 'bar'],
      content: contentA
    });

    view.set('layerNeedsUpdate', NO);
  }
});

test('should dirty layer when content changes', function () {
  view.set('content', contentB);
  ok(view.get('layerNeedsUpdate'));
});

test('should dirty layer when any of contentDisplayProperties change', function () {
  contentA.set('foo', 'newFoo');
  ok(view.get('layerNeedsUpdate'));
});

test('should stop observing old content when content changes', function () {
  ok(contentA.hasObserverFor('*'));
  view.set('content', contentB);
  ok(!contentA.hasObserverFor('*'));
});

test('should begin observing new content when content changes', function () {
  view.set('content', contentB);
  view.set('layerNeedsUpdate', NO);
  contentB.set('bar', 'newBar');
  ok(view.get('layerNeedsUpdate'));
});

test('should stop observing content when destroyed', function () {
  ok(contentA.hasObserverFor('*'));
  view.destroy();
  ok(!contentA.hasObserverFor('*'));
});

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.2 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.2-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.1 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.rc.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js
sproutcore-1.6.0.beta.3-x86-mingw32 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/content_display.js