diff --git a/test/colors.coffee b/test/colors.coffee deleted file mode 100644 index a555dcd..0000000 --- a/test/colors.coffee +++ /dev/null @@ -1,13 +0,0 @@ - -should = require 'should' -import pad from '../src' - -describe 'colors', -> - - it 'should pad right', (next) -> - pad('\u001b[33mabc\u001b[39m', 6, colors: true).should.eql '\u001b[33mabc\u001b[39m ' - next() - - it 'should pad left with an additionnal option', (next) -> - pad(6, '\u001b[33mabc\u001b[39m', char: '-', colors: true).should.eql '---\u001b[33mabc\u001b[39m' - next() diff --git a/test/option.char.coffee b/test/option.char.coffee new file mode 100644 index 0000000..c567be7 --- /dev/null +++ b/test/option.char.coffee @@ -0,0 +1,13 @@ + +should = require 'should' +import pad from '../src' + +describe 'option.char', -> + + it 'should pad right', -> + pad('yeah', 6, '-').should.eql 'yeah--' + pad('yeah', 6, char: '-').should.eql 'yeah--' + + it 'should pad left', -> + pad(6, '234', '0').should.eql '000234' + pad(6, '234', char: '0').should.eql '000234' diff --git a/test/option.colors.coffee b/test/option.colors.coffee new file mode 100644 index 0000000..0c87c25 --- /dev/null +++ b/test/option.colors.coffee @@ -0,0 +1,13 @@ + +should = require 'should' +import pad from '../src' + +describe 'option.colors', -> + + it 'should pad right', -> + pad('\u001b[33mabc\u001b[39m', 6, colors: true) + .should.eql '\u001b[33mabc\u001b[39m ' + + it 'should pad left with an additionnal option', -> + pad(6, '\u001b[33mabc\u001b[39m', char: '-', colors: true) + .should.eql '---\u001b[33mabc\u001b[39m' diff --git a/test/option.fixed_width.coffee b/test/option.fixed_width.coffee new file mode 100644 index 0000000..50ce466 --- /dev/null +++ b/test/option.fixed_width.coffee @@ -0,0 +1,11 @@ + +should = require 'should' +import pad from '../src' + +describe 'option.fixed_width', -> + + it 'characters with more than one colum', -> + # 2 chinese characters + chars = Buffer.from("e6938de4bd9c", 'hex').toString() + pad(6, chars).length.should.eql 4 + pad(6, chars, fixed_width: true).length.should.eql 6 diff --git a/test/option.strip.coffee b/test/option.strip.coffee new file mode 100644 index 0000000..a483949 --- /dev/null +++ b/test/option.strip.coffee @@ -0,0 +1,11 @@ + +should = require 'should' +import pad from '../src' + +describe 'option.strip', -> + + it 'strip if text longer than length', -> + pad(2, 'abcdef', strip: true).should.eql 'ef' + + it 'strip if text longer than length', -> + pad('abcdef', 2, strip: true).should.eql 'ab' diff --git a/test/pad.coffee b/test/pad.coffee index b82904b..07d2132 100644 --- a/test/pad.coffee +++ b/test/pad.coffee @@ -12,24 +12,6 @@ describe 'pad', -> it 'should pad left', -> pad(6, 'abc').should.eql ' abc' - it 'should pad right', -> - pad('yeah', 6, '-').should.eql 'yeah--' - - it 'should pad left', -> - pad(6, '234', '0').should.eql '000234' - it 'accept length inferior to text', -> pad(0, 'foo').should.eql 'foo' - - it 'strip if text longer than length', -> - pad(2, 'abcdef', strip: true).should.eql 'ef' - - it 'strip if text longer than length', -> - pad('abcdef', 2, strip: true).should.eql 'ab' - - it 'characters with more than one colum', -> - # 2 chinese characters - chars = Buffer.from("e6938de4bd9c", 'hex').toString() - pad(6, chars).length.should.eql 4 - pad(6, chars, fixed_width: true).length.should.eql 6