-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminal.test.js
163 lines (154 loc) · 5.32 KB
/
terminal.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const { mtrim } = require('js-trim-multiline-string');
test('use echo true command to verify exec child_process working correctly', async (done) => {
const { stdout, stderr } = await exec('echo "true"');
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(stdout).toBe(
`true
`.mtrim()
)
done();
});
test('verify folder structure prior to @availity/workflow scaffold', async (done) => {
const { stdout, stderr } = await exec('ls');
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(stdout).toBe(
`Readme.md
node_modules
package-lock.json
package.json
run_terminal.js
terminal.test.js
`.mtrim()
)
done();
});
test('providing correct results for @availity/workflow scaffold', async (done) => {
const { stdout, stderr } = await exec('npx @availity/workflow init info --package angular');
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(JSON.stringify(stdout)).toEqual(
expect.stringContaining('Success!')
)
expect(JSON.stringify(stdout)).not.toEqual(
expect.stringContaining('Successs!')
)
done();
// expect(stdout).toBe(
// expect.stringContaining(
// `
// › Creating a new @availity/workflow-plugin-angular app in /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info.
//
// › Installing packages. This might take a couple of minutes.
// › Installing @availity/workflow-plugin-angular...
//
//
// > fsevents@1.2.9 install /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/fsevents
// > node install
//
// [fsevents] Success: "/Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
//
// > node-sass@4.12.0 install /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/node-sass
// > node scripts/install.js
//
// Cached binary found at /Users/michaeldimmitt/.npm/node-sass/4.12.0/darwin-x64-57_binding.node
//
// > node-sass@4.12.0 postinstall /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/node-sass
// > node scripts/build.js
//
// Binary found at /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/node-sass/vendor/darwin-x64-57/binding.node
// Testing binary
// Binary is fine
// + @availity/workflow-plugin-angular@5.3.1
// added 1360 packages from 668 contributors and audited 887180 packages in 36.511s
// found 0 vulnerabilities
//
// › Installing dependencies using npm...
//
//
// > fsevents@1.2.7 install /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/fsevents
// > node install
//
// [fsevents] Success: "/Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" is installed via remote
// added 491 packages from 270 contributors, removed 55 packages, updated 177 packages, moved 4 packages and audited 968067 packages in 44.398s
// found 12 vulnerabilities (8 moderate, 4 high)
// run \`npm audit fix\` to fix them, or \`npm audit\` for details
//
// ✔ Success! Created info at /Users/michaeldimmitt/new_c/97_lunchpool/simp-js_term/info
// › Inside that directory, you can run several commands:
// ›
// › npm start
// › Starts the development server.
// ›
// › npm run build
// › Bundles the app into static files for production.
// ›
// › npm test
// › Starts the test runner.
// ›
// › We suggest that you begin by typing:
// › cd info
// › npm start
// `.mtrim()
// )
// )
}, 300000);
test('check new angular folder in directory', async (done) => {
const { stdout, stderr } = await exec('mkdir info; ls');
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(stdout).toBe(
`Readme.md
info
node_modules
package-lock.json
package.json
run_terminal.js
terminal.test.js
`.mtrim()
)
done();
});
// test('check new angular folder in directory', async (done) => {
// const { stdout, stderr } = await execo('ls')
// console.log({ stdout, stderr })
// expect(stdout)
// .toBe('Readme.md info node_modules package-lock.json package.json run_terminal.js terminal.test.js')
// done();
// });
test('cleanup project removing scaffolded angular application', async (done) => {
const { stdout, stderr } = await exec('rm -rf info; ls')
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(stdout).toBe(
`Readme.md
node_modules
package-lock.json
package.json
run_terminal.js
terminal.test.js
`.mtrim()
)
done();
}, 30000 );
test('show the ping command in action', async (done) => {
const { stdout, stderr } = await exec('ping 8.8.8.8 -c 2')
console.log('stdout: ',stdout,'\n','stderr: ',stderr);
expect(stdout)
.toEqual(
expect.stringContaining(
'PING 8.8.8.8 (8.8.8.8): 56 data bytes'
)
)
expect(stdout)
.toEqual(
expect.stringContaining(
'64 bytes from 8.8.8.8: icmp_seq=0 ttl='
)
)
expect(stdout)
.toEqual(
expect.stringContaining(
'64 bytes from 8.8.8.8: icmp_seq=1 ttl='
)
)
done();
});