Skip to content

Commit

Permalink
make toString() implicit since the classes are named identically
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Feb 10, 2018
1 parent ac7bbe5 commit 04ca169
Showing 1 changed file with 4 additions and 36 deletions.
40 changes: 4 additions & 36 deletions packages/expect/src/asymmetric_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class AsymmetricMatcher {
constructor() {
this.$$typeof = Symbol.for('jest.asymmetricMatcher');
}

toString() {
return this.constructor.name;
}
}

class Any extends AsymmetricMatcher {
Expand Down Expand Up @@ -63,10 +67,6 @@ class Any extends AsymmetricMatcher {
return other instanceof this.sample;
}

toString() {
return 'Any';
}

getExpectedType() {
if (this.sample == String) {
return 'string';
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -136,10 +132,6 @@ class ArrayContaining extends AsymmetricMatcher {
);
}

toString() {
return 'ArrayContaining';
}

getExpectedType() {
return 'array';
}
Expand All @@ -149,10 +141,6 @@ class ArrayNotContaining extends ArrayContaining {
asymmetricMatch(other: Array<any>) {
return !super.asymmetricMatch(other);
}

toString() {
return 'ArrayNotContaining';
}
}

class ObjectContaining extends AsymmetricMatcher {
Expand Down Expand Up @@ -184,10 +172,6 @@ class ObjectContaining extends AsymmetricMatcher {
return true;
}

toString() {
return 'ObjectContaining';
}

getExpectedType() {
return 'object';
}
Expand Down Expand Up @@ -216,10 +200,6 @@ class ObjectNotContaining extends ObjectContaining {

return true;
}

toString() {
return 'ObjectNotContaining';
}
}

class StringContaining extends AsymmetricMatcher {
Expand All @@ -241,10 +221,6 @@ class StringContaining extends AsymmetricMatcher {
return other.includes(this.sample);
}

toString() {
return 'StringContaining';
}

getExpectedType() {
return 'string';
}
Expand All @@ -254,10 +230,6 @@ class StringNotContaining extends StringContaining {
asymmetricMatch(other: string) {
return !super.asymmetricMatch(other);
}

toString() {
return 'StringNotContaining';
}
}

class StringMatching extends AsymmetricMatcher {
Expand All @@ -280,10 +252,6 @@ class StringMatching extends AsymmetricMatcher {
return this.sample.test(other);
}

toString() {
return 'StringMatching';
}

getExpectedType() {
return 'string';
}
Expand Down

0 comments on commit 04ca169

Please sign in to comment.