Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Expect other to only be a string
  • Loading branch information
rogeliog committed Jan 5, 2018
commit 4d9bb831818621b28f782ae7340edb196afef41e
2 changes: 1 addition & 1 deletion packages/expect/src/asymmetric_matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class StringMatching extends AsymmetricMatcher {
}

asymmetricMatch(other: string) {
if (!isA('String', other) && !isA('RegExp', other)) {
if (!isA('String', other)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to our docs, stringMatching() accepts a regexp. Mind changing the type and runtime check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @rogeliog can you take a look at this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thymikee The StringMatching constructor does indeed take either string or RegExp, but argument of the asymmetricMatch function takes only string as received value, true?

That is, expect.stringMatching(/^Alic/) returns true when the received value is 'Alicia' or false when the received value is 'Bob' but should report an error if the received value is a RegExp, because how to decide if a received RegExp matches an expected RegExp?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrottimark you're right, I mistaken other with sample

return false;
}

Expand Down