mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 15:02:22 +00:00
1325fb8c9a
Simplify expect semantics in tests. Change-type: patch Signed-off-by: Scott Lowe <scott@balena.io>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { expect } 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');
|
|
|
|
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');
|
|
|
|
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(''));
|
|
|
|
expect(json).to.deep.equal({
|
|
'balena-cli': packageJSON.version,
|
|
'Node.js': nodeVersion,
|
|
});
|
|
});
|
|
});
|