File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ function enable(namespaces) {
141
141
exports . names = [ ] ;
142
142
exports . skips = [ ] ;
143
143
144
- var split = ( namespaces || '' ) . split ( / [ \s , ] + / ) ;
144
+ var split = ( typeof namespaces === 'string' ? namespaces : '' ) . split ( / [ \s , ] + / ) ;
145
145
var len = split . length ;
146
146
147
147
for ( var i = 0 ; i < len ; i ++ ) {
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ var chai
6
6
, debug
7
7
, sinon
8
8
, sinonChai ;
9
-
9
+
10
10
if ( typeof module !== 'undefined' ) {
11
11
chai = require ( 'chai' ) ;
12
12
expect = chai . expect ;
13
-
13
+
14
14
debug = require ( '../src/index' ) ;
15
15
sinon = require ( 'sinon' ) ;
16
16
sinonChai = require ( "sinon-chai" ) ;
@@ -20,28 +20,32 @@ if (typeof module !== 'undefined') {
20
20
21
21
describe ( 'debug' , function ( ) {
22
22
var log = debug ( 'test' ) ;
23
-
23
+
24
24
log . log = sinon . stub ( ) ;
25
-
25
+
26
26
it ( 'passes a basic sanity check' , function ( ) {
27
27
expect ( log ( 'hello world' ) ) . to . not . throw ;
28
28
} ) ;
29
29
30
+ it ( 'allows namespaces to be a non-string value' , function ( ) {
31
+ expect ( debug . enable ( true ) ) . to . not . throw ;
32
+ } ) ;
33
+
30
34
context ( 'with log function' , function ( ) {
31
-
35
+
32
36
beforeEach ( function ( ) {
33
37
debug . enable ( 'test' ) ;
34
38
log = debug ( 'test' ) ;
35
39
} ) ;
36
-
40
+
37
41
it ( 'uses it' , function ( ) {
38
42
log . log = sinon . stub ( ) ;
39
43
log ( 'using custom log function' ) ;
40
44
41
45
expect ( log . log ) . to . have . been . calledOnce ;
42
46
} ) ;
43
47
} ) ;
44
-
48
+
45
49
describe ( 'custom functions' , function ( ) {
46
50
var log ;
47
51
@@ -59,4 +63,5 @@ describe('debug', function () {
59
63
} ) ;
60
64
} ) ;
61
65
} ) ;
66
+
62
67
} ) ;
You can’t perform that action at this time.
0 commit comments