Blame view

node_modules/text-table/test/ansi-colors.js 892 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  var test = require('tape');
  var table = require('../');
  var color = require('cli-color');
  var ansiTrim = require('cli-color/lib/trim');
  
  test('center', function (t) {
      t.plan(1);
      var opts = {
          align: [ 'l', 'c', 'l' ],
          stringLength: function(s) { return ansiTrim(s).length }
      };
      var s = table([
          [
              color.red('Red'), color.green('Green'), color.blue('Blue')
          ],
          [
              color.bold('Bold'), color.underline('Underline'),
              color.italic('Italic')
          ],
          [
              color.inverse('Inverse'), color.strike('Strike'),
              color.blink('Blink')
          ],
          [ 'bar', '45', 'lmno' ]
      ], opts);
      t.equal(ansiTrim(s), [
          'Red        Green    Blue',
          'Bold     Underline  Italic',
          'Inverse    Strike   Blink',
          'bar          45     lmno'
      ].join('\n'));
  });