mirror of
https://github.com/flynx/colors.js.git
synced 2025-11-01 12:30:14 +00:00
Merge pull request #20 from cjc/master
[fix] Theme properties return object when mode == 'none'
This commit is contained in:
commit
e9604a5194
@ -98,7 +98,7 @@ function stylize(str, style) {
|
|||||||
'yellow' : ['<span style="color:yellow;">', '</span>']
|
'yellow' : ['<span style="color:yellow;">', '</span>']
|
||||||
};
|
};
|
||||||
} else if (exports.mode === 'none') {
|
} else if (exports.mode === 'none') {
|
||||||
return str;
|
return str+'';
|
||||||
} else {
|
} else {
|
||||||
console.log('unsupported mode, try "browser", "console" or "none"');
|
console.log('unsupported mode, try "browser", "console" or "none"');
|
||||||
}
|
}
|
||||||
|
|||||||
10
test.js
10
test.js
@ -46,6 +46,11 @@ aE(s, 'red', 31);
|
|||||||
aE(s, 'yellow', 33);
|
aE(s, 'yellow', 33);
|
||||||
assert.equal(s, 'string');
|
assert.equal(s, 'string');
|
||||||
|
|
||||||
|
colors.setTheme({error:'red'});
|
||||||
|
|
||||||
|
assert.equal(typeof("astring".red),'string');
|
||||||
|
assert.equal(typeof("astring".error),'string');
|
||||||
|
|
||||||
colors.mode = 'browser';
|
colors.mode = 'browser';
|
||||||
assert.equal(s.bold, '<b>' + s + '</b>');
|
assert.equal(s.bold, '<b>' + s + '</b>');
|
||||||
assert.equal(s.italic, '<i>' + s + '</i>');
|
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(colors[color](s), h(s, color));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
assert.equal(typeof("astring".red),'string');
|
||||||
|
assert.equal(typeof("astring".error),'string');
|
||||||
|
|
||||||
colors.mode = 'none';
|
colors.mode = 'none';
|
||||||
stylesAll.forEach(function (style) {
|
stylesAll.forEach(function (style) {
|
||||||
assert.equal(s[style], s);
|
assert.equal(s[style], s);
|
||||||
assert.equal(colors[style](s), s);
|
assert.equal(colors[style](s), s);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
assert.equal(typeof("astring".red),'string');
|
||||||
|
assert.equal(typeof("astring".error),'string');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user