Sha256: 8a4fadfe907d84ea912f3266851926e79088efc8311c7ef21f0295648080455e

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

// ==========================================================================
// 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 */

var pane = SC.ControlTestPane.design()
  .add("basic", SC.View.extend(SC.Control, SC.Button, 
    {
      localize: YES,
      displayProperties: ['title'],
      render: function(context, firstTime) {
        this.renderTitle(context, firstTime);
      },
      title: "Hello World"
    })
  );

pane.show();

module('SC.Button ui', {
  setup: function() {
    htmlbody('<style> .sc-static-layout { border: 1px red dotted; } </style>');
    var view = pane.view('basic');
  },
  teardown: function(){
    clearHtmlbody();
  }
});

test("should set the innerHTML to the title", function() {
  var view = pane.view('basic');
  
  ok(view.$('label'), 'button has no label');
  var label = view.$('label');
  
  ok(label[0], 'label has no html node');
  var htmlNode = label[0];
  
  equals(htmlNode.innerHTML, 'Hello World', 'innerHTML should be set to title');
});

test("should modify the innerHTML if the title changes", function() {
  var view = pane.view('basic');
  
  SC.RunLoop.begin();
  view.set('title', 'Goodbye World');
  SC.RunLoop.end();
  
  var label = view.$('label');
  var htmlNode = label[0];
  
  equals(htmlNode.innerHTML, 'Goodbye World', 'innerHTML should be modified when title changes');
});

test("should still modify the innerHTML if the title changes and then changes back to previous value", function() {
  var view = pane.view('basic');
  
  SC.RunLoop.begin();
  view.set('title', 'Hello World');
  SC.RunLoop.end();
  
  var label = view.$('label');
  var htmlNode = label[0];
  
  equals(htmlNode.innerHTML, 'Hello World', 'innerHTML should be modified when title changes and then changes back to original value');
});

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/foundation/tests/mixins/button/ui.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/button/ui.js