mirror of
https://github.com/debug-js/debug.git
synced 2026-01-25 16:42:28 +00:00
Fix bug that would occure if process.env.DEBUG is a non-string value. (#444)
Connects to #443
This commit is contained in:
parent
2f3ebf49c1
commit
1f01b70f88
@ -141,7 +141,7 @@ function enable(namespaces) {
|
||||
exports.names = [];
|
||||
exports.skips = [];
|
||||
|
||||
var split = (namespaces || '').split(/[\s,]+/);
|
||||
var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
|
||||
@ -6,11 +6,11 @@ var chai
|
||||
, debug
|
||||
, sinon
|
||||
, sinonChai;
|
||||
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
chai = require('chai');
|
||||
expect = chai.expect;
|
||||
|
||||
|
||||
debug = require('../src/index');
|
||||
sinon = require('sinon');
|
||||
sinonChai = require("sinon-chai");
|
||||
@ -20,20 +20,24 @@ if (typeof module !== 'undefined') {
|
||||
|
||||
describe('debug', function () {
|
||||
var log = debug('test');
|
||||
|
||||
|
||||
log.log = sinon.stub();
|
||||
|
||||
|
||||
it('passes a basic sanity check', function () {
|
||||
expect(log('hello world')).to.not.throw;
|
||||
});
|
||||
|
||||
it('allows namespaces to be a non-string value', function () {
|
||||
expect(debug.enable(true)).to.not.throw;
|
||||
});
|
||||
|
||||
context('with log function', function () {
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
debug.enable('test');
|
||||
log = debug('test');
|
||||
});
|
||||
|
||||
|
||||
it('uses it', function () {
|
||||
log.log = sinon.stub();
|
||||
log('using custom log function');
|
||||
@ -41,7 +45,7 @@ describe('debug', function () {
|
||||
expect(log.log).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('custom functions', function () {
|
||||
var log;
|
||||
|
||||
@ -59,4 +63,5 @@ describe('debug', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user