Skip to content

Commit

Permalink
Add "Too many arguments" message to info and improve code coverage (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
skratchdot authored and wyze committed Dec 13, 2016
1 parent 8515f9b commit b1166d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion __tests__/commands/info.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -47,7 +48,7 @@ const expectedKeys = [
];

test.concurrent('without arguments and in directory containing a valid package file', (): Promise<void> => {
return runInfo(['.'], {}, 'local',
return runInfo([], {}, 'local',
(config, output): ?Promise<void> => {
const actualKeys = Object.keys(output);
expectedKeys.forEach((key) => expect(actualKeys).toContain(key));
Expand Down Expand Up @@ -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<void> => {
const reporter = new reporters.ConsoleReporter({});
return runInfo(['YARN.invalid.package.name.YARN'], {}, '',
(config, output): ?Promise<void> => {
expect(output).toContain(reporter.lang('infoFail', 2));
},
);
});

test.concurrent('reports error with too many arguments', (): Promise<void> => {
const reporter = new reporters.ConsoleReporter({});
return runInfo(['yarn', 'version', 'extra.invalid.arg'], {}, '',
(config, output): ?Promise<void> => {
expect(output).toContain(reporter.lang('tooManyArguments', 2));
},
);
});
1 change: 1 addition & 0 deletions src/cli/commands/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function run(
args: Array<string>,
): Promise<void> {
if (args.length > 2) {
reporter.error(reporter.lang('tooManyArguments', 2));
return;
}

Expand Down

0 comments on commit b1166d7

Please sign in to comment.