Skip to content

Commit

Permalink
feat(regexps): add toBeRegExp matcher
Browse files Browse the repository at this point in the history
closes #25, #64
  • Loading branch information
jacobwardio authored and JamieMason committed Jan 14, 2017
1 parent a4f060a commit c983e3c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Marcin Wosinek (https://github.com/marcin-wosinek)",
"Mathieu Robin (https://github.com/MathRobin)",
"Sam L'ecuyer (https://github.com/samlecuyer)",
"Vilmos Ioo (https://github.com/vilmosioo)"
"Vilmos Ioo (https://github.com/vilmosioo)",
"Jacob Ward (https://github.com/jacobwarduk"
],
"dependencies": {
"jasmine-matchers-loader": "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module.exports = {
toBeNumber: require('./toBeNumber'),
toBeObject: require('./toBeObject'),
toBeOddNumber: require('./toBeOddNumber'),
toBeRegExp: require('./toBeRegExp'),
toBeSameLengthAs: require('./toBeSameLengthAs'),
toBeShorterThan: require('./toBeShorterThan'),
toBeString: require('./toBeString'),
Expand Down
4 changes: 4 additions & 0 deletions src/toBeRegExp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// public
module.exports = function toBeRegExp(actual) {
return actual instanceof RegExp;
};
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module.exports = {
toBeNumber: require('./toBeNumber.spec'),
toBeObject: require('./toBeObject.spec'),
toBeOddNumber: require('./toBeOddNumber.spec'),
toBeRegExp: require('./toBeRegExp.spec'),
toBeSameLengthAs: require('./toBeSameLengthAs.spec'),
toBeShorterThan: require('./toBeShorterThan.spec'),
toBeString: require('./toBeString.spec'),
Expand Down
18 changes: 18 additions & 0 deletions test/toBeRegExp.spec.js
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();
});
});
});
});

0 comments on commit c983e3c

Please sign in to comment.