Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50660 views
1
/*
2
* log-test.js: Tests for cliff.
3
*
4
* (C) 2010, Nodejitsu Inc.
5
*
6
*/
7
8
var assert = require('assert'),
9
vows = require('vows'),
10
eyes = require('eyes'),
11
cliff = require('../lib/cliff');
12
13
vows.describe('cliff').addBatch({
14
"When using cliff module": {
15
"the columnMajor() method": {
16
"should respond with rows in column major form": function () {
17
var columns, rows = [
18
["1a", "2a", "3a", "4a"],
19
["1b", "2b", "3b", "4b"],
20
["1c", "2c", "3c", "4c"]
21
];
22
23
columns = cliff.columnMajor(rows);
24
for (var i = 0; i < columns.length; i++) {
25
columns[i].forEach(function (val) {
26
assert.isTrue(val.indexOf(i + 1) !== -1);
27
});
28
}
29
}
30
},
31
"the arrayLengths() method": {
32
"with a set of strings": {
33
"should respond with a list of the longest elements": function () {
34
var lengths, rows = [
35
["1a", "2a", "3a", "4a"],
36
["1b", "2bb", "3b", "4b"],
37
["1c", "2c", "3ccc", "4c"],
38
["1d", "2d", "3dd", "4dddd"]
39
];
40
41
lengths = cliff.arrayLengths(rows);
42
assert.equal(lengths[0], 2);
43
assert.equal(lengths[1], 3);
44
assert.equal(lengths[2], 4);
45
assert.equal(lengths[3], 5);
46
}
47
},
48
"with a set of numbers and strings": {
49
"should respond with a list of the longest elements": function () {
50
var lengths, rows = [
51
[11, "2a", "3a", "4a"],
52
["1b", 222, "3b", "4b"],
53
["1c", "2c", 3333, "4c"],
54
["1d", "2d", "3dd", 44444]
55
];
56
57
lengths = cliff.arrayLengths(rows);
58
assert.equal(lengths[0], 2);
59
assert.equal(lengths[1], 3);
60
assert.equal(lengths[2], 4);
61
assert.equal(lengths[3], 5);
62
}
63
}
64
},
65
"the stringifyRows() method": {
66
"should calculate padding correctly for numbers": function() {
67
var rows = [
68
['a', 'b'],
69
[12345, 1]
70
];
71
72
assert.equal(
73
cliff.stringifyRows(rows),
74
'a b \n12345 1 '
75
);
76
}
77
}
78
}
79
}).export(module);
80