From e8b007bce7d5dfcf3adef83a693cd45d82bf854a Mon Sep 17 00:00:00 2001 From: ninevra Date: Sun, 25 Oct 2020 21:32:36 -0700 Subject: [PATCH] Match ObjectNotContaining documentation --- packages/expect/src/asymmetricMatchers.ts | 33 +++++++---------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/packages/expect/src/asymmetricMatchers.ts b/packages/expect/src/asymmetricMatchers.ts index b20f3052ca97..c906f247e742 100644 --- a/packages/expect/src/asymmetricMatchers.ts +++ b/packages/expect/src/asymmetricMatchers.ts @@ -7,7 +7,6 @@ */ import {equals, fnNameFor, hasProperty, isA, isUndefined} from './jasmineUtils'; -import {emptyObject} from './utils'; export class AsymmetricMatcher { protected sample: T; @@ -162,31 +161,19 @@ class ObjectContaining extends AsymmetricMatcher> { ); } - if (this.inverse) { - for (const property in this.sample) { - if ( - hasProperty(other, property) && - equals(this.sample[property], other[property]) && - !emptyObject(this.sample[property]) && - !emptyObject(other[property]) - ) { - return false; - } - } + let result = true; - return true; - } else { - for (const property in this.sample) { - if ( - !hasProperty(other, property) || - !equals(this.sample[property], other[property]) - ) { - return false; - } + for (const property in this.sample) { + if ( + !hasProperty(other, property) || + !equals(this.sample[property], other[property]) + ) { + result = false; + break; } - - return true; } + + return this.inverse ? !result : result; } toString() {