Rename hashContaining to objectContaining, since this is javascript. Also call the toString from prettyPrinter
This commit is contained in:
@@ -238,11 +238,11 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
||||
return b.matches(a);
|
||||
}
|
||||
|
||||
if (a instanceof jasmine.Matchers.HashContaining) {
|
||||
if (a instanceof jasmine.Matchers.ObjectContaining) {
|
||||
return a.matches(b);
|
||||
}
|
||||
|
||||
if (b instanceof jasmine.Matchers.HashContaining) {
|
||||
if (b instanceof jasmine.Matchers.ObjectContaining) {
|
||||
return b.matches(a);
|
||||
}
|
||||
|
||||
|
||||
@@ -369,11 +369,11 @@ jasmine.Matchers.Any.prototype.toString = function() {
|
||||
return '<jasmine.any(' + this.expectedClass + ')>';
|
||||
};
|
||||
|
||||
jasmine.Matchers.HashContaining = function (sample) {
|
||||
jasmine.Matchers.ObjectContaining = function (sample) {
|
||||
this.sample = sample;
|
||||
};
|
||||
|
||||
jasmine.Matchers.HashContaining.prototype.matches = function(other, mismatchKeys, mismatchValues) {
|
||||
jasmine.Matchers.ObjectContaining.prototype.matches = function(other, mismatchKeys, mismatchValues) {
|
||||
mismatchKeys = mismatchKeys || [];
|
||||
mismatchValues = mismatchValues || [];
|
||||
|
||||
@@ -395,6 +395,6 @@ jasmine.Matchers.HashContaining.prototype.matches = function(other, mismatchKeys
|
||||
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
|
||||
};
|
||||
|
||||
jasmine.Matchers.HashContaining.prototype.toString = function () {
|
||||
return "<jasmine.hashContaining(" + jasmine.pp(this.sample) + ")>";
|
||||
jasmine.Matchers.ObjectContaining.prototype.toString = function () {
|
||||
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
|
||||
};
|
||||
|
||||
@@ -25,6 +25,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||
this.emitScalar('<global>');
|
||||
} else if (value instanceof jasmine.Matchers.Any) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (value instanceof jasmine.Matchers.ObjectContaining) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'string') {
|
||||
this.emitString(value);
|
||||
} else if (jasmine.isSpy(value)) {
|
||||
|
||||
@@ -197,18 +197,18 @@ jasmine.any = function(clazz) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a matchable subset of a hash/JSON object. For use in expectations when you don't care about all of the
|
||||
* Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
|
||||
* attributes on the object.
|
||||
*
|
||||
* @example
|
||||
* // don't care about any other attributes than foo.
|
||||
* expect(mySpy).toHaveBeenCalledWith(jasmine.hashContaining({foo: "bar"});
|
||||
* expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
|
||||
*
|
||||
* @param sample {Object} sample
|
||||
* @returns matchable object for the sample
|
||||
*/
|
||||
jasmine.hashContaining = function (sample) {
|
||||
return new jasmine.Matchers.HashContaining(sample);
|
||||
jasmine.objectContaining = function (sample) {
|
||||
return new jasmine.Matchers.ObjectContaining(sample);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user