-
-
Notifications
You must be signed in to change notification settings - Fork 245
/
Copy pathcustom-labels.js
110 lines (99 loc) · 3.89 KB
/
custom-labels.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"use strict"
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const assert = require("power-assert")
const util = require("./lib/util")
const BufferStream = require("./lib/buffer-stream")
const removeResult = util.removeResult
const runPar = util.runPar
//------------------------------------------------------------------------------
// Test
//------------------------------------------------------------------------------
describe("[custom labels]", () => {
before(() => process.chdir("test-workspace"))
after(() => process.chdir(".."))
beforeEach(removeResult)
describe("should use the given label instead of script name", () => {
const EXPECTED_LINES = [
"[Unit Test ] abcabc",
"[Unit Test ] abc",
"[Unit Test ] abcabc",
"[Unit Test ] abc",
"[Unit Test ] abc",
"[Unit Test ] abc",
"[Unit Test ] abc",
"[Unit Test ] abc",
"[Unit Test ] ",
"[Unit Test ] abc",
"[Unit Test ] abcabc",
"[Unit Test ] ",
"[Unit Test ] ",
"[Unit Test ] ",
"[Unit Test ] abc",
"[test-task:echo def] defdef",
"[test-task:echo def] def",
"[test-task:echo def] defdef",
"[test-task:echo def] def",
"[test-task:echo def] def",
"[test-task:echo def] def",
"[test-task:echo def] def",
"[test-task:echo def] def",
"[test-task:echo def] ",
"[test-task:echo def] def",
"[test-task:echo def] defdef",
"[test-task:echo def] ",
"[test-task:echo def] ",
"[test-task:echo def] ",
"[test-task:echo def] def",
]
it("npm-run-all --labels=\"Unit Test\"", async () => {
const stdout = new BufferStream()
await runPar(["test-task:echo abc", "test-task:echo def", "--silent", "--print-label", "--labels=Unit Test"], stdout)
for (const line of stdout.value.split(/\n\r?/g)) {
assert(EXPECTED_LINES.includes(line), `Missing line: ${line}`)
}
})
})
describe("should use all given label instead of script name", () => {
const EXPECTED_LINES = [
"[Unit Test 1] abcabc",
"[Unit Test 1] abc",
"[Unit Test 1] abcabc",
"[Unit Test 1] abc",
"[Unit Test 1] abc",
"[Unit Test 1] abc",
"[Unit Test 1] abc",
"[Unit Test 1] abc",
"[Unit Test 1] ",
"[Unit Test 1] abc",
"[Unit Test 1] abcabc",
"[Unit Test 1] ",
"[Unit Test 1] ",
"[Unit Test 1] ",
"[Unit Test 1] abc",
"[Unit Test 2] defdef",
"[Unit Test 2] def",
"[Unit Test 2] defdef",
"[Unit Test 2] def",
"[Unit Test 2] def",
"[Unit Test 2] def",
"[Unit Test 2] def",
"[Unit Test 2] def",
"[Unit Test 2] ",
"[Unit Test 2] def",
"[Unit Test 2] defdef",
"[Unit Test 2] ",
"[Unit Test 2] ",
"[Unit Test 2] ",
"[Unit Test 2] def",
]
it("npm-run-all --labels=\"Unit Test 1,Unit Test 2\"", async () => {
const stdout = new BufferStream()
await runPar(["test-task:echo abc", "test-task:echo def", "--silent", "--print-label", "--labels=Unit Test 1,Unit Test 2"], stdout)
for (const line of stdout.value.split(/\n\r?/g)) {
assert(EXPECTED_LINES.includes(line), `Missing line: ${line}`)
}
})
})
})