Sha256: d7d65da888aea8abe5404e969eb26e13200633c6e5bd52bcb2b81d0db899d466

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

describe("ObjectContaining", function() {

  it("matches any actual to an empty object", function() {
    var containing = new j$.ObjectContaining({});

    expect(containing.asymmetricMatch("foo")).toBe(true);
  });

  it("does not match an empty object actual", function() {
    var containing = new j$.ObjectContaining("foo");

    expect(function() {
      containing.asymmetricMatch({})
    }).toThrowError(/not 'foo'/)
  });

  it("matches when the key/value pair is present in the actual", function() {
    var containing = new j$.ObjectContaining({foo: "fooVal"});

    expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(true);
  });

  it("does not match when the key/value pair is not present in the actual", function() {
    var containing = new j$.ObjectContaining({foo: "fooVal"});

    expect(containing.asymmetricMatch({bar: "barVal", quux: "quuxVal"})).toBe(false);
  });

  it("does not match when the key is present but the value is different in the actual", function() {
    var containing = new j$.ObjectContaining({foo: "other"});

    expect(containing.asymmetricMatch({foo: "fooVal", bar: "barVal"})).toBe(false);
  });

  it("jasmineToString's itself", function() {
    var containing = new j$.ObjectContaining({});

    expect(containing.jasmineToString()).toMatch("<jasmine.objectContaining");
  });

  it("matches recursively", function() {
    var containing = new j$.ObjectContaining({one: new j$.ObjectContaining({two: {}})});

    expect(containing.asymmetricMatch({one: {two: {}}})).toBe(true);
  });

  it("matches when key is present with undefined value", function() {
    var containing = new j$.ObjectContaining({ one: undefined });

    expect(containing.asymmetricMatch({ one: undefined })).toBe(true);
  });

  it("does not match when key with undefined value is not present", function() {
    var containing = new j$.ObjectContaining({ one: undefined });

    expect(containing.asymmetricMatch({})).toBe(false);
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jasmine-core-2.2.0 ./lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js