forked from hazeledmands/nsrun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
123 lines (112 loc) · 3.22 KB
/
test.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
111
112
113
114
115
116
117
118
119
120
121
122
123
const nixt = require("nixt");
describe("At end arguments", function() {
it("runs the scripts you define in package.json", function(done) {
nixt()
.run("./nsrun.js monkey-facts")
.stdout("Monkeys are fun")
.stderr("")
.code(0)
.end(done);
});
it("runs the scripts you define in package.json with arguments", function(done) {
nixt()
.run("./nsrun.js monkey-facts when asleep")
.stdout("Monkeys are fun when asleep")
.stderr("")
.code(0)
.end(done);
});
it("runs nested scripts with nsrun instead of npm run", function(done) {
nixt()
.run("./nsrun.js tell-me-about-monkeys")
.stdout("Monkeys are fun\nMonkeys are frequently cheeky")
.stderr("")
.code(0)
.end(done);
});
it("exits with the same code as the script", function(done) {
nixt()
.run("./nsrun.js fail")
.stdout("")
.stderr("")
.code(1)
.end(done);
});
it("outputs all the scripts in package.json with no arguments", function(done) {
nixt()
.run("./nsrun.js")
.stdout(
[
"13 scripts in ./package.json:",
" * test",
" * monkey-facts",
" * more-monkey-facts",
" * tell-me-about-monkeys",
" * give-a-monkey-name",
" * monkeys-dreams",
" * more-monkeys-dreams",
" * monkeys-knows-nothing",
" * premonkey-ride",
" * monkey-ride",
" * postmonkey-ride",
" * fail",
" * precommit"
].join("\n")
)
.stderr("")
.code(0)
.end(done);
});
});
describe("Positionned arguments", function() {
it("runs the scripts you define in package.json with $1 argument", function(done) {
nixt()
.run("./nsrun.js give-a-monkey-name monkymonk")
.stdout("My monkey as that stupid name : monkymonk")
.stderr("")
.code(0)
.end(done);
});
it("runs the scripts you define in package.json with $* arguments", function(done) {
nixt()
.run("./nsrun.js monkeys-dreams flowers trees grasses and no ice creams")
.stdout(
"Monkeys dreams of flowers trees grasses and no ice creams, sometimes"
)
.stderr("")
.code(0)
.end(done);
});
it("runs the scripts you define in package.json with few arguments", function(done) {
nixt()
.run(
"./nsrun.js more-monkeys-dreams flowers trees sleeps for an ice creams"
)
.stdout(
"Monkeys dreams 2 things : trees and flowers, sometimes it sleeps for an ice creams"
)
.stderr("")
.code(0)
.end(done);
});
it("runs the scripts you define in package.json with bad arguments", function(done) {
nixt()
.run("./nsrun.js monkeys-knows-nothing just like john snow")
.stdout("")
.stderr(
"The script (monkeys-knows-nothing) expected additional positional arguments!"
)
.code(1)
.end(done);
});
});
describe("Run pre and post scripts" ,function(){
it("runs the scripts with pre and post scripts", function (done) {
nixt()
.run("./nsrun.js monkey-ride")
.stdout("Ride on\nGo monkey!\nRide off")
.stderr("")
.code(0)
.end(done);
});
});