Sha256: 933c0be642cf5ea03ae6195c7461955640054303ca815046e2ec8b9f5c817e67

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents

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

/*global module test equals context ok */

module("SC.View");

test("setting themeName should trigger a theme observer", function() {
  var count = 0;
  var view = SC.View.create({
    themeDidChange: function() {
      count++;
    }.observes('theme'),
  });

  view.set('themeName', 'hello');
  equals(1, count, "theme observers should get called");
});

test("setting themeName should trigger a theme observer when extending", function() {
  var count = 0;
  var View = SC.View.extend({
    themeDidChange: function() {
      count++;
    }.observes('theme'),
  });

  View.create().set('themeName', 'hello');
  equals(1, count, "theme observers should get called");
});

test("it still works with the backward compatible theme property", function() {
  var count = 0;
  var view = SC.View.create({
    theme: 'sc-base',
    themeDidChange: function() {
      count++;
    }.observes('theme'),
  });

  equals(SC.Theme.find('sc-base'), view.get('theme'));
  view.set('themeName', 'hello');
  equals(1, count, "theme observers should get called");
});

test("it still works with the backward compatible theme property when extending", function() {
  var count = 0;
  var View = SC.View.extend({
    theme: 'sc-base',
    themeDidChange: function() {
      count++;
    }.observes('theme'),
  });

  view = View.create();
  equals(SC.Theme.find('sc-base'), view.get('theme'));
  view.set('themeName', 'hello');
  equals(1, count, "theme observers should get called");
});

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/core_foundation/tests/views/view/view.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/amber/tests/views/view/view.js