balena-cli/tests/commands/version.spec.ts
Lucian 730c09989d Fix incorrect arguments passed to oclif bootstrap function
Adds tests for existing oclif commands to avoid regressions

Change-type: patch
Signed-off-by: Lucian <lucian.buzzo@gmail.com>
2019-08-15 18:26:42 +01:00

38 lines
1.0 KiB
TypeScript

import * as chai from 'chai';
import * as fs from 'fs';
import { runCommand } from '../helpers';
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');
chai.expect(out.join('')).to.equal(`${packageJSON.version}\n`);
});
it('should print additional version information with the -a flag', async () => {
const { out } = await runCommand('version -a');
chai.expect(out.join('')).to.equal(
`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(''));
chai.expect(json).to.deep.equal({
'balena-cli': packageJSON.version,
'Node.js': nodeVersion,
});
});
});