forked from ljacobsson/cfn-diagram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.js
36 lines (30 loc) · 1.15 KB
/
index.spec.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
let os = require('os');
let path = require('path');
let exec = require('child_process').exec;
test('Code should be 0', async () => {
jest.setTimeout(30000);
console.log("output path set to " + os.tmpdir() + '/template.drawio')
let result = await cli(['draw.io', '--template-file', './tests/template.json', '--output-file', os.tmpdir() + '/template.drawio', '--ci-mode' ], '.');
console.log(result.stdout)
console.log(result.stderr)
expect(result.code).toBe(0);
console.log("output path set to " + os.tmpdir())
result = await cli(['html', '--template-file', './tests/template.json', '--output-path', os.tmpdir(), '--ci-mode'], '.');
console.log(result.stdout)
console.log(result.stderr)
expect(result.code).toBe(0);
})
function cli(args, cwd) {
return new Promise(resolve => {
exec(`node ${path.resolve('./index.js')} ${args.join(' ')}`,
{ cwd },
(error, stdout, stderr) => {
resolve({
code: error && error.code ? error.code : 0,
error,
stdout,
stderr
})
})
})
}