-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathauttomatic-cli-table-tests.js
executable file
·64 lines (58 loc) · 1.96 KB
/
auttomatic-cli-table-tests.js
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
54
55
56
57
58
59
60
61
62
63
64
require("../test/example-utils.js").quickInit()
const Table = require("../")("automattic-cli-table")
/* col widths */
const t1 = new Table({
head: ["Rel", "Change", "By", "When"],
colWidths: [6, 21, 25, 17]
})
t1.push(
["v0.1", "Testing something cool", "[email protected]", "7 minutes ago"]
, ["v0.1", "Testing something cool", "[email protected]", "8 minutes ago"]
)
console.log(t1.toString())
/* compact */
const t2 = new Table({
head: ["Rel", "Change", "By", "When"],
colWidths: [6, 21, 25, 17],
style: { compact: true, "padding-left": 1 }
})
t2.push(
["v0.1", "Testing something cool", "[email protected]", "7 minutes ago"]
, ["v0.1", "Testing something cool", "[email protected]", "8 minutes ago"]
, []
, ["v0.1", "Testing something cool", "[email protected]", "8 minutes ago"]
)
console.log(t2.toString())
/* headless */
var headlessTable = new Table()
headlessTable.push(["v0.1", "Testing something cool", "[email protected]", "7 minutes ago"])
console.log(headlessTable.toString())
/* vertical */
var verticalTable = new Table({
style: {
head: ["green"]
}
})
verticalTable.push({ "Some Key": "Some Value" },
{ "Another much longer key": "And its corresponding longer value" }
)
console.log(verticalTable.toString())
/* cross */
var crossTable = new Table({ head: ["", "Header #1", "Header #2"] })
crossTable.push({ "Header #3": ["Value 1", "Value 2"] },
{ "Header #4": ["Value 3", "Value 4"] })
console.log(crossTable.toString())
/* additional to improve code coverage */
const misc = new Table({
head: ["Rel", "Change", "By", "When"],
colWidths: [6, 21, 25, 17],
colAligns: ["left", "left", "right", "right"],
style: { compact: true, "padding-right": 1, body: ["green"] }
})
misc.push(
["v0.1", "Testing something cool", "[email protected]", "7 minutes ago"]
, ["v0.1", "Testing something cool", "[email protected]", "8 minutes ago"]
, []
, ["v0.1", "Testing something cool", "[email protected]", "8 minutes ago"]
)
console.log(misc.toString())