Skip to content

Commit

Permalink
Add unit tests for find
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanalderson committed Nov 8, 2012
1 parent bef8050 commit 8d32754
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions test/grep.js
Expand Up @@ -4,27 +4,27 @@ var Mocha = require('../');
describe('Mocha', function(){
describe('"grep" option', function(){
it('should add a RegExp to the mocha.options object', function(){
var mocha = new Mocha({ grep: /foo/ });
mocha.options.grep.toString().should.equal('/foo/');
var mocha = new Mocha({ grep: /foo()/ });
mocha.options.grep.toString().should.equal('/foo()/');
})

it('should convert grep string to a RegExp', function(){
var mocha = new Mocha({ grep: 'foo' });
mocha.options.grep.toString().should.equal('/foo/');
var mocha = new Mocha({ grep: 'foo()' });
mocha.options.grep.toString().should.equal('/foo()/');
})
})

describe('.grep()', function(){
it('should add a RegExp to the mocha.options object', function(){
var mocha = new Mocha;
mocha.grep(/foo/);
mocha.options.grep.toString().should.equal('/foo/');
mocha.grep(/foo()/);
mocha.options.grep.toString().should.equal('/foo()/');
})

it('should convert grep string to a RegExp', function(){
var mocha = new Mocha;
mocha.grep('foo');
mocha.options.grep.toString().should.equal('/foo/');
mocha.grep('foo()');
mocha.options.grep.toString().should.equal('/foo()/');
})

it('should return it\'s parent Mocha object for chainability', function(){
Expand All @@ -33,6 +33,37 @@ describe('Mocha', function(){
})
})

describe('"find" option', function(){
it('should add a RegExp to the mocha.options object', function(){
var mocha = new Mocha({ find: /foo()/ });
mocha.options.grep.toString().should.equal('/foo()/');
})

it('should convert find string to an escaped RegExp', function(){
var mocha = new Mocha({ find: 'foo()' });
mocha.options.grep.toString().should.equal('/foo\\(\\)/');
})
})

describe('.find()', function(){
it('should add a RegExp to the mocha.options object', function(){
var mocha = new Mocha;
mocha.find(/foo()/);
mocha.options.grep.toString().should.equal('/foo()/');
})

it('should convert find string to an escaped RegExp', function(){
var mocha = new Mocha;
mocha.find('foo()');
mocha.options.grep.toString().should.equal('/foo\\(\\)/');
})

it('should return it\'s parent Mocha object for chainability', function(){
var mocha = new Mocha;
mocha.find().should.equal(mocha);
})
})

describe('"invert" option', function(){
it('should add a Boolean to the mocha.options object', function(){
var mocha = new Mocha({ invert: true });
Expand Down

0 comments on commit 8d32754

Please sign in to comment.