-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
26 lines (20 loc) · 729 Bytes
/
test.js
File metadata and controls
26 lines (20 loc) · 729 Bytes
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
// @flow
'use strict';
const child = require('child_process');
const path = require('path');
const bin = path.join(__dirname, 'bin.js');
function exec(command, script = '') {
return child.execSync(`${bin} ${script} ${command}`, { stdio: 'pipe' }).toString();
}
test('success', () => {
expect(JSON.parse(exec('SUCCESS --foo 1'))).toEqual({ opts: { foo: 1 } });
});
test('failure', () => {
expect(() => { exec('FAILURE'); }).toThrow('Oops');
});
test('unserializable', () => {
expect(() => { exec('UNSERIALIZABLE'); }).toThrow('Converting circular structure to JSON');
});
test('custom projector file', () => {
expect(JSON.parse(exec('SUCCESS --foo 1', './projector-custom.js'))).toEqual({ opts: { foo: 1 } });
});