1
1
'use strict' ;
2
2
3
- var path = require ( 'path' ) . posix ;
4
3
var helpers = require ( '../helpers' ) ;
5
4
var runMocha = helpers . runMocha ;
6
5
var runMochaJSON = helpers . runMochaJSON ;
7
6
8
- describe ( '--grep' , function ( ) {
9
- var args = [ ] ;
10
- var fixture = path . join ( 'options' , 'grep' ) ;
11
-
12
- afterEach ( function ( ) {
13
- args = [ ] ;
14
- } ) ;
7
+ var FIXTURE = 'options/grep' ;
15
8
9
+ describe ( '--grep' , function ( ) {
16
10
it ( 'should run specs matching a string' , function ( done ) {
17
- args = [ '--grep' , 'match' ] ;
18
- runMochaJSON ( fixture , args , function ( err , res ) {
11
+ runMochaJSON ( FIXTURE , [ '--grep' , 'match' ] , function ( err , res ) {
19
12
if ( err ) {
20
13
return done ( err ) ;
21
14
}
@@ -27,9 +20,8 @@ describe('--grep', function() {
27
20
} ) ;
28
21
29
22
describe ( 'should run specs matching a RegExp' , function ( ) {
30
- it ( 'with RegExp-like strings (pattern follow by flag)' , function ( done ) {
31
- args = [ '--grep' , '/match/i' ] ;
32
- runMochaJSON ( fixture , args , function ( err , res ) {
23
+ it ( 'with RegExp-like strings (pattern followed by flag)' , function ( done ) {
24
+ runMochaJSON ( FIXTURE , [ '--grep' , '/match/i' ] , function ( err , res ) {
33
25
if ( err ) {
34
26
return done ( err ) ;
35
27
}
@@ -41,8 +33,7 @@ describe('--grep', function() {
41
33
} ) ;
42
34
43
35
it ( 'with string as pattern' , function ( done ) {
44
- args = [ '--grep' , '.*' ] ;
45
- runMochaJSON ( fixture , args , function ( err , res ) {
36
+ runMochaJSON ( FIXTURE , [ '--grep' , '.*' ] , function ( err , res ) {
46
37
if ( err ) {
47
38
return done ( err ) ;
48
39
}
@@ -55,10 +46,9 @@ describe('--grep', function() {
55
46
} ) ;
56
47
} ) ;
57
48
58
- describe ( 'when --invert used ' , function ( ) {
49
+ describe ( 'when used with --invert' , function ( ) {
59
50
it ( 'should run specs that do not match the pattern' , function ( done ) {
60
- args = [ '--grep' , 'fail' , '--invert' ] ;
61
- runMochaJSON ( fixture , args , function ( err , res ) {
51
+ runMochaJSON ( FIXTURE , [ '--grep' , 'fail' , '--invert' ] , function ( err , res ) {
62
52
if ( err ) {
63
53
return done ( err ) ;
64
54
}
@@ -68,40 +58,22 @@ describe('--grep', function() {
68
58
done ( ) ;
69
59
} ) ;
70
60
} ) ;
61
+ } ) ;
71
62
72
- it ( 'should throw an error when option used in isolation' , function ( done ) {
73
- var spawnOpts = { stdio : 'pipe' } ;
74
- args = [ '--invert' ] ;
63
+ describe ( 'when both --fgrep and --grep used together' , function ( ) {
64
+ it ( 'should report an error' , function ( done ) {
75
65
runMocha (
76
- fixture ,
77
- args ,
66
+ FIXTURE ,
67
+ [ '--fgrep' , 'first' , '--grep' , 'second' ] ,
78
68
function ( err , res ) {
79
69
if ( err ) {
80
70
return done ( err ) ;
81
71
}
82
- expect ( res , 'to satisfy' , {
83
- code : 1 ,
84
- output : / - - i n v e r t .* - - g r e p < r e g e x p > /
85
- } ) ;
72
+ expect ( res , 'to have failed with output' , / m u t u a l l y e x c l u s i v e / i) ;
86
73
done ( ) ;
87
74
} ,
88
- spawnOpts
75
+ 'pipe'
89
76
) ;
90
77
} ) ;
91
78
} ) ;
92
-
93
- describe ( 'when both --fgrep and --grep used together' , function ( ) {
94
- it ( 'should conflict' , function ( done ) {
95
- // var fixture = 'uncaught.fixture.js';
96
- args = [ '--fgrep' , 'first' , '--grep' , 'second' ] ;
97
-
98
- runMocha ( fixture , args , function ( err , res ) {
99
- if ( err ) {
100
- return done ( err ) ;
101
- }
102
- expect ( res , 'to have failed' ) ;
103
- done ( ) ;
104
- } ) ;
105
- } ) ;
106
- } ) ;
107
79
} ) ;
0 commit comments