2019-11-15 09:45:14 +00:00
|
|
|
import { expect } from 'chai';
|
2019-08-09 17:36:52 +00:00
|
|
|
import * as fs from 'fs';
|
2019-08-15 12:40:55 +00:00
|
|
|
import { runCommand } from '../helpers';
|
2019-08-09 17:36:52 +00:00
|
|
|
|
|
|
|
const packageJSON = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
|
|
|
const nodeVersion = process.version.startsWith('v')
|
|
|
|
? process.version.slice(1)
|
|
|
|
: process.version;
|
|
|
|
|
|
|
|
describe('balena version', function() {
|
|
|
|
it('should print the installed version of the CLI', async () => {
|
|
|
|
const { out } = await runCommand('version');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(out.join('')).to.equal(`${packageJSON.version}\n`);
|
2019-08-09 17:36:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should print additional version information with the -a flag', async () => {
|
|
|
|
const { out } = await runCommand('version -a');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(out.join('')).to.equal(
|
2019-08-09 17:36:52 +00:00
|
|
|
`balena-cli version "${packageJSON.version}"
|
|
|
|
Node.js version "${nodeVersion}"
|
|
|
|
`,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should print version information as JSON with the the -j flag', async () => {
|
|
|
|
const { out } = await runCommand('version -j');
|
|
|
|
|
|
|
|
const json = JSON.parse(out.join(''));
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(json).to.deep.equal({
|
2019-08-09 17:36:52 +00:00
|
|
|
'balena-cli': packageJSON.version,
|
|
|
|
'Node.js': nodeVersion,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|