File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ function enable(namespaces) {
141141 exports . names = [ ] ;
142142 exports . skips = [ ] ;
143143
144- var split = ( namespaces || '' ) . split ( / [ \s , ] + / ) ;
144+ var split = ( typeof namespaces === 'string' ? namespaces : '' ) . split ( / [ \s , ] + / ) ;
145145 var len = split . length ;
146146
147147 for ( var i = 0 ; i < len ; i ++ ) {
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ var chai
66 , debug
77 , sinon
88 , sinonChai ;
9-
9+
1010if ( typeof module !== 'undefined' ) {
1111 chai = require ( 'chai' ) ;
1212 expect = chai . expect ;
13-
13+
1414 debug = require ( '../src/index' ) ;
1515 sinon = require ( 'sinon' ) ;
1616 sinonChai = require ( "sinon-chai" ) ;
@@ -20,28 +20,32 @@ if (typeof module !== 'undefined') {
2020
2121describe ( 'debug' , function ( ) {
2222 var log = debug ( 'test' ) ;
23-
23+
2424 log . log = sinon . stub ( ) ;
25-
25+
2626 it ( 'passes a basic sanity check' , function ( ) {
2727 expect ( log ( 'hello world' ) ) . to . not . throw ;
2828 } ) ;
2929
30+ it ( 'allows namespaces to be a non-string value' , function ( ) {
31+ expect ( debug . enable ( true ) ) . to . not . throw ;
32+ } ) ;
33+
3034 context ( 'with log function' , function ( ) {
31-
35+
3236 beforeEach ( function ( ) {
3337 debug . enable ( 'test' ) ;
3438 log = debug ( 'test' ) ;
3539 } ) ;
36-
40+
3741 it ( 'uses it' , function ( ) {
3842 log . log = sinon . stub ( ) ;
3943 log ( 'using custom log function' ) ;
4044
4145 expect ( log . log ) . to . have . been . calledOnce ;
4246 } ) ;
4347 } ) ;
44-
48+
4549 describe ( 'custom functions' , function ( ) {
4650 var log ;
4751
@@ -59,4 +63,5 @@ describe('debug', function () {
5963 } ) ;
6064 } ) ;
6165 } ) ;
66+
6267} ) ;
You can’t perform that action at this time.
0 commit comments