Sha256: c5f2f6de9da5fa3ff443695128a4f34c5e5a592ca8b76711ea22347547dd6d5b

Contents?: true

Size: 1.63 KB

Versions: 30

Compression:

Stored size: 1.63 KB

Contents

var object, methodSpy;
module('CoreTest.spyOn', {
  setup: function() {
    object = {method: function() {}};
    methodSpy = CoreTest.spyOn(object, 'method');
  }
});

test('when the spied upon method was called spy#wasCalled is true', function() {
  object.method();

  ok(methodSpy.wasCalled, 'spy should know that it was called');
});

test('when the spied upon method was not called spy#wasCalled is false', function() {
  ok(!methodSpy.wasCalled, 'spy should know that it was not called');
});

test('when the spied upon method is called with a single argument the spy should know when it was called with the proper arguments', function() {
  object.method('something');

  ok(methodSpy.wasCalledWith('something'), 'spy should know it was called with the proper arguments');
});

test('when the spied upon method is called with multiple arguments the spy should know when it was called with the proper arguments', function() {
  object.method('something', 'else');

  ok(methodSpy.wasCalledWith('something', 'else'), 'spy should know it was called with the proper arguments');
});

test('when the spied upon method is called with a single argument the spy should know when it was called with the wrong arguments', function() {
  object.method('something');

  ok(!methodSpy.wasCalledWith('else'), 'spy should know it was called with the wrong arguments');
});

test('when the spied upon method is called with multiple arguments the spy should know when it was called with the wrong arguments', function() {
  object.method('something', 'else');

  ok(!methodSpy.wasCalledWith('else', 'something'), 'spy should know it was called with the wrong arguments');
});

Version data entries

30 entries across 30 versions & 1 rubygems

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