diff --git a/__tests__/commands/info.js b/__tests__/commands/info.js index f42b0c7260..bfa8749605 100644 --- a/__tests__/commands/info.js +++ b/__tests__/commands/info.js @@ -1,5 +1,6 @@ /* @flow */ +import * as reporters from '../../src/reporters/index.js'; import {run as info} from '../../src/cli/commands/info.js'; import {BufferReporter} from '../../src/reporters/index.js'; import Config from '../../src/config.js'; @@ -47,7 +48,7 @@ const expectedKeys = [ ]; test.concurrent('without arguments and in directory containing a valid package file', (): Promise => { - return runInfo(['.'], {}, 'local', + return runInfo([], {}, 'local', (config, output): ?Promise => { const actualKeys = Object.keys(output); expectedKeys.forEach((key) => expect(actualKeys).toContain(key)); @@ -127,3 +128,21 @@ test.concurrent('with two arguments and second argument path containing non-exis }, ); }); + +test.concurrent('reports error on invalid package names', (): Promise => { + const reporter = new reporters.ConsoleReporter({}); + return runInfo(['YARN.invalid.package.name.YARN'], {}, '', + (config, output): ?Promise => { + expect(output).toContain(reporter.lang('infoFail', 2)); + }, + ); +}); + +test.concurrent('reports error with too many arguments', (): Promise => { + const reporter = new reporters.ConsoleReporter({}); + return runInfo(['yarn', 'version', 'extra.invalid.arg'], {}, '', + (config, output): ?Promise => { + expect(output).toContain(reporter.lang('tooManyArguments', 2)); + }, + ); +}); diff --git a/src/cli/commands/info.js b/src/cli/commands/info.js index 4ee248f914..51ec22197b 100644 --- a/src/cli/commands/info.js +++ b/src/cli/commands/info.js @@ -43,6 +43,7 @@ export async function run( args: Array, ): Promise { if (args.length > 2) { + reporter.error(reporter.lang('tooManyArguments', 2)); return; }