Fixed objectContaining to not match when the expected is the empty object and the actual is a non-object

This commit is contained in:
Steve Gravrock
2019-11-02 14:22:16 -07:00
parent 71631a6529
commit 8d53f4d202
3 changed files with 12 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
ObjectContaining.prototype.asymmetricMatch = function(other, customTesters) {
if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
// TODO: This succeeds when sample is an empty object and other is a non-object, but should probably fail
if (typeof(other) !== 'object') { return false; }
for (var property in this.sample) {
if (!hasProperty(other, property) ||