arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/colors/tests/safe-test.js
www/node_modules/colors/tests/safe-test.jsRaw
 1var assert = require('assert'),
 2    colors = require('../safe');
 3
 4var s = 'string';
 5
 6function a(s, code) {
 7  return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m';
 8}
 9
10function aE(s, color, code) {
11  assert.equal(colors[color](s), a(s, code));
12  assert.equal(colors.strip(s), s);
13}
14
15function h(s, color) {
16  return '<span style="color:' + color + ';">' + s + '</span>';
17}
18
19var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
20var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);
21
22colors.mode = 'console';
23assert.equal(colors.bold(s), '\x1B[1m' + s + '\x1B[22m');
24assert.equal(colors.italic(s), '\x1B[3m' + s + '\x1B[23m');
25assert.equal(colors.underline(s), '\x1B[4m' + s + '\x1B[24m');
26assert.equal(colors.strikethrough(s), '\x1B[9m' + s + '\x1B[29m');
27assert.equal(colors.inverse(s), '\x1B[7m' + s + '\x1B[27m');
28
29assert.ok(colors.rainbow);
30
31aE(s, 'white', 37);
32aE(s, 'grey', 90);
33aE(s, 'black', 30);
34aE(s, 'blue', 34);
35aE(s, 'cyan', 36);
36aE(s, 'green', 32);
37aE(s, 'magenta', 35);
38aE(s, 'red', 31);
39aE(s, 'yellow', 33);
40
41assert.equal(s, 'string');
42colors.setTheme({error:'red'});
43
44assert.equal(typeof(colors.red("astring")), 'string');
45assert.equal(typeof(colors.error("astring")), 'string');