forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue mochajs#325 - add better grep support to js api
- Loading branch information
1 parent
c9d183c
commit 58cd48e
Showing
2 changed files
with
63 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var Mocha = require('../../'); | ||
|
||
describe('Mocha', function(){ | ||
|
||
beforeEach(function(){ | ||
this.reEqual = function(r1, r2){ | ||
return r1.source === r2.source | ||
&& r1.global === r2.global | ||
&& r1.ignoreCase === r2.ignoreCase | ||
&& r1.multiline === r2.multiline; | ||
} | ||
}) | ||
|
||
describe('constructor options.grep', function(){ | ||
it('should add a RegExp to the mocha.options object', function(){ | ||
var mocha = new Mocha({grep:/foo/}); | ||
this.reEqual(/foo/, mocha.options.grep).should.be.ok; | ||
}) | ||
|
||
it('should convert grep string to a RegExp', function(){ | ||
var mocha = new Mocha({grep:'foo'}); | ||
this.reEqual(/foo/, mocha.options.grep).should.be.ok; | ||
}) | ||
}) | ||
|
||
describe('.grep()', function(){ | ||
it('should add a RegExp to the mocha.options object', function(){ | ||
var mocha = new Mocha(); | ||
mocha.grep(/foo/); | ||
this.reEqual(/foo/, mocha.options.grep).should.be.ok; | ||
}) | ||
|
||
it('should convert grep string to a RegExp', function(){ | ||
var mocha = new Mocha(); | ||
mocha.grep('foo'); | ||
this.reEqual(/foo/, mocha.options.grep).should.be.ok; | ||
}) | ||
|
||
it('should return it\'s parent Mocha object for chainability', function(){ | ||
var mocha = new Mocha(); | ||
mocha.grep().should.equal(mocha); | ||
}) | ||
}) | ||
}) |