From 3aed695b4903d02e32473b96dcadf8612cb283af Mon Sep 17 00:00:00 2001 From: cjc Date: Thu, 19 Jan 2012 18:51:41 +1000 Subject: [PATCH 1/2] Add tests for return type of color and theme properties --- test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test.js b/test.js index 1c03d65..d74432a 100644 --- a/test.js +++ b/test.js @@ -46,6 +46,11 @@ aE(s, 'red', 31); aE(s, 'yellow', 33); assert.equal(s, 'string'); +colors.setTheme({error:'red'}); + +assert.equal(typeof("astring".red),'string'); +assert.equal(typeof("astring".error),'string'); + colors.mode = 'browser'; assert.equal(s.bold, '' + s + ''); assert.equal(s.italic, '' + s + ''); @@ -57,9 +62,14 @@ stylesColors.forEach(function (color) { assert.equal(colors[color](s), h(s, color)); }); +assert.equal(typeof("astring".red),'string'); +assert.equal(typeof("astring".error),'string'); + colors.mode = 'none'; stylesAll.forEach(function (style) { assert.equal(s[style], s); assert.equal(colors[style](s), s); }); +assert.equal(typeof("astring".red),'string'); +assert.equal(typeof("astring".error),'string'); From 5ca667df4a9f86f6c202eca5eb1524cd8d2dd331 Mon Sep 17 00:00:00 2001 From: cjc Date: Thu, 19 Jan 2012 20:23:50 +1000 Subject: [PATCH 2/2] Fix to coerce object input back to string in null stylize operation --- colors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colors.js b/colors.js index b981317..e4b14ec 100644 --- a/colors.js +++ b/colors.js @@ -96,7 +96,7 @@ function stylize(str, style) { 'yellow' : ['', ''] }; } else if (exports.mode === 'none') { - return str; + return str+''; } else { console.log('unsupported mode, try "browser", "console" or "none"'); } @@ -301,4 +301,4 @@ function zalgo(text, options) { // don't summon zalgo addProperty('zalgo', function () { return zalgo(this); -}); \ No newline at end of file +});