Sha256: 11fdd94f9f6425e598a4c1679e9f90602ed948dcac3a13f278641c3c8ea596e3

Contents?: true

Size: 1.52 KB

Versions: 55

Compression:

Stored size: 1.52 KB

Contents

describe("toHaveBeenCalled", function() {
  it("passes when the actual was called, with a custom .not fail message", function() {
    var matcher = j$.matchers.toHaveBeenCalled(),
      calledSpy = j$.createSpy('called-spy'),
      result;

    calledSpy();

    result = matcher.compare(calledSpy);
    expect(result.pass).toBe(true);
    expect(result.message).toEqual("Expected spy called-spy not to have been called.");
  });

  it("fails when the actual was not called", function() {
    var matcher = j$.matchers.toHaveBeenCalled(),
      uncalledSpy = j$.createSpy('uncalled spy'),
      result;

    result = matcher.compare(uncalledSpy);
    expect(result.pass).toBe(false);
  });

  it("throws an exception when the actual is not a spy", function() {
    var matcher = j$.matchers.toHaveBeenCalled(),
      fn = function() {};

    expect(function() { matcher.compare(fn) }).toThrow(new Error("Expected a spy, but got Function."));
  });

  it("throws an exception when invoked with any arguments", function() {
    var matcher = j$.matchers.toHaveBeenCalled(),
      spy = j$.createSpy('sample spy');

    expect(function() { matcher.compare(spy, 'foo') }).toThrow(new Error("toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith"));
  });

  it("has a custom message on failure", function() {
    var matcher = j$.matchers.toHaveBeenCalled(),
      spy = j$.createSpy('sample-spy'),
      result;

    result = matcher.compare(spy);

    expect(result.message).toEqual("Expected spy sample-spy to have been called.");
  });
});

Version data entries

55 entries across 55 versions & 4 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/bootstrap-tagsinput/lib/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.2 vendor/bundle/gems/jasmine-core-2.4.1/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.1 vendor/bundle/gems/jasmine-core-2.4.1/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.4.1 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.4.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.11.0 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.5 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.4 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.3 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.2 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.1 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.10.0 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.9.1 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.9.0 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.8.2 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.8.1 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.8.0 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.7.8 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.7.7 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js
upjs-rails-0.7.6 spec_app/vendor/assets/bower_components/jasmine/spec/core/matchers/toHaveBeenCalledSpec.js