printalbe_test.js
1.67 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var should = require('should');
var pt = require('../');
var source;
describe('printable test', function() {
describe('common print', function() {
it('should print limit ok', function() {
source = [['hello', 'world'], ['foo', 'bar']];
var out = pt.print(source, '|', 10);
out.should.equal('hello |world \nfoo |bar ');
});
it('should print unlimit ok', function() {
var out = pt.print(source, '|')
out.should.equal('hello|world\nfoo |bar ');
});;
it('should print limit cut ok', function() {
var out = pt.print(source, ' | ', 3);
out.should.equal('hel | wor\nfoo | bar');
});
it('should print border length ok',function() {
var out = pt.print(source, 5);
out.should.equal('hello world\nfoo bar ');
});
it('should print chinese ok', function() {
source = [['hello', 'world'], ['你好', '世界']];
var out = pt.print(source, '|');
out.should.equal('hello|world\n你好 |世界 ');
});
it('should cut chinese ok', function() {
var out = pt.print(source, '|', 3);
out.should.equal('hel|wor\n你 |世 ');
});
});
describe('!string print', function() {
it('should print number ok', function() {
source.push(['number', 123456789]);
var out = pt.print(source, '|');
out.should.equal('hello |world \n你好 |世界 \nnumber|123456789');
});
it('should print object ok', function() {
source.push([{a:"1"}, ['我',2]]);
var out = pt.print(source, '|');
out.should.equal('hello |world \n你好 |世界 \nnumber |123456789\n{"a":"1"}|["我",2] ');
});
});
});