From 04ca1690b28772cec78eb90456deddfdf0379423 Mon Sep 17 00:00:00 2001 From: Evan Scott Date: Sat, 10 Feb 2018 18:14:05 -0500 Subject: [PATCH] make toString() implicit since the classes are named identically --- packages/expect/src/asymmetric_matchers.js | 40 +++------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/packages/expect/src/asymmetric_matchers.js b/packages/expect/src/asymmetric_matchers.js index 4945ef6668aa..71f524336e0f 100644 --- a/packages/expect/src/asymmetric_matchers.js +++ b/packages/expect/src/asymmetric_matchers.js @@ -23,6 +23,10 @@ class AsymmetricMatcher { constructor() { this.$$typeof = Symbol.for('jest.asymmetricMatcher'); } + + toString() { + return this.constructor.name; + } } class Any extends AsymmetricMatcher { @@ -63,10 +67,6 @@ class Any extends AsymmetricMatcher { return other instanceof this.sample; } - toString() { - return 'Any'; - } - getExpectedType() { if (this.sample == String) { return 'string'; @@ -101,10 +101,6 @@ class Anything extends AsymmetricMatcher { return !isUndefined(other) && other !== null; } - toString() { - return 'Anything'; - } - // No getExpectedType method, because it matches either null or undefined. toAsymmetricMatcher() { @@ -136,10 +132,6 @@ class ArrayContaining extends AsymmetricMatcher { ); } - toString() { - return 'ArrayContaining'; - } - getExpectedType() { return 'array'; } @@ -149,10 +141,6 @@ class ArrayNotContaining extends ArrayContaining { asymmetricMatch(other: Array) { return !super.asymmetricMatch(other); } - - toString() { - return 'ArrayNotContaining'; - } } class ObjectContaining extends AsymmetricMatcher { @@ -184,10 +172,6 @@ class ObjectContaining extends AsymmetricMatcher { return true; } - toString() { - return 'ObjectContaining'; - } - getExpectedType() { return 'object'; } @@ -216,10 +200,6 @@ class ObjectNotContaining extends ObjectContaining { return true; } - - toString() { - return 'ObjectNotContaining'; - } } class StringContaining extends AsymmetricMatcher { @@ -241,10 +221,6 @@ class StringContaining extends AsymmetricMatcher { return other.includes(this.sample); } - toString() { - return 'StringContaining'; - } - getExpectedType() { return 'string'; } @@ -254,10 +230,6 @@ class StringNotContaining extends StringContaining { asymmetricMatch(other: string) { return !super.asymmetricMatch(other); } - - toString() { - return 'StringNotContaining'; - } } class StringMatching extends AsymmetricMatcher { @@ -280,10 +252,6 @@ class StringMatching extends AsymmetricMatcher { return this.sample.test(other); } - toString() { - return 'StringMatching'; - } - getExpectedType() { return 'string'; }