/
info.test.js
28 lines (25 loc) · 933 Bytes
/
info.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
const { sync: spawnSync } = require('execa');
const path = require('path');
describe('Info', () => {
it('should run with cli', () => {
const { stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info'], {
cwd: path.resolve(__dirname),
reject: false,
});
expect(stdout).toContain('System');
expect(stdout).toContain('Binaries');
expect(stdout).toContain('OS');
});
it('should work with flags', () => {
const { stdout } = spawnSync(path.resolve(__dirname, '../bin/cli.js'), ['info', '--output=json'], {
cwd: path.resolve(__dirname),
reject: false,
});
const testJSON = () => {
const output = JSON.parse(stdout);
expect(output['System']).toBeTruthy();
expect(output['System']['OS']).toBeTruthy();
};
expect(testJSON).not.toThrow();
});
});