-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(regexps): add toBeRegExp matcher
- Loading branch information
1 parent
a4f060a
commit c983e3c
Showing
5 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// public | ||
module.exports = function toBeRegExp(actual) { | ||
return actual instanceof RegExp; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// spec | ||
describe('toBeRegExp', function () { | ||
describe('when invoked', function () { | ||
describe('when value is an instance of RegExp', function () { | ||
it('should confirm', function () { | ||
expect(new RegExp()).toBeRegExp(); | ||
expect(/abc/).toBeRegExp(); | ||
}); | ||
}); | ||
describe('when value is not an instance of RegExp', function () { | ||
it('should deny', function () { | ||
expect(null).not.toBeRegExp(); | ||
expect(function () {}).not.toBeRegExp(); | ||
expect('abc').not.toBeRegExp(); | ||
}); | ||
}); | ||
}); | ||
}); |