Sha256: 1c92e5c69a6ff316bd67d5ec8177ae4af3d5dff971d4b94474d0900cd49e9d36

Contents?: true

Size: 1.61 KB

Versions: 30

Compression:

Stored size: 1.61 KB

Contents

var button, rootResponder, pane, expectedAction, targetObject, sendActionSpy;

module("SC.Button", {
  setup: function() {
    expectedAction = 'myAction';
    targetObject = SC.Object.create({
      myAction: function() {
      }
    });

    var rootResponder = {sendAction: function(){} };
    sendActionSpy = CoreTest.spyOn(rootResponder, 'sendAction');

    pane = SC.Object.create({
      rootResponder: rootResponder
    });

    button = SC.Button.create({
      target: targetObject,
      action: 'myAction',
      pane: pane
    });
  }
});

test("#mouseUp - triggers the action when mouse is over the button", function() {
  button.set('isActive', true);

  button.mouseUp();

  ok(sendActionSpy.wasCalledWith(expectedAction, targetObject, button, pane, null, button), 'triggers the action');
});

test("#mouseUp - does not trigger action if mouse is not over the button", function() {
  button.set('isActive', false);

  button.mouseUp();
  ok(!sendActionSpy.wasCalled, 'should not trigger the action');
});

test('#mouseUp - makes the button no longer active', function () {
  button.set('isActive', true);
  button.mouseUp();

  equals(button.get('isActive'), false, 'should set the button to not be active');
});

test('#mouseDown - makes the button active', function() {
  button.set('isActive', false);
  button.mouseDown();

  equals(button.get('isActive'), true, 'should set the button to be active');
});

test('#mouseExited - makes but button no longer active', function() {
  button.set('isActive', false);
  button.mouseExited();

  equals(button.get('isActive'), false, 'should set the button to no longer be active');
});

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/template_view/tests/controls/button.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/controls/button.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/core_foundation/tests/controls/button.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/core_foundation/tests/controls/button.js