Merge pull request #20 from cjc/master

[fix] Theme properties return object when mode == 'none'
This commit is contained in:
Marak 2012-09-05 21:33:45 -07:00
commit e9604a5194
2 changed files with 11 additions and 1 deletions

View File

@ -98,7 +98,7 @@ function stylize(str, style) {
'yellow' : ['<span style="color:yellow;">', '</span>']
};
} else if (exports.mode === 'none') {
return str;
return str+'';
} else {
console.log('unsupported mode, try "browser", "console" or "none"');
}

10
test.js
View File

@ -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, '<b>' + s + '</b>');
assert.equal(s.italic, '<i>' + s + '</i>');
@ -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');