Compare commits

..

No commits in common. "b2722b487ea8c7cecc682616a3d7601eb37351e9" and "91f974be9d80f935efb98003814824c3d517d63b" have entirely different histories.

3 changed files with 2 additions and 28 deletions

View file

@ -9,8 +9,7 @@ program
.name('random-bunny')
.description('Get a random image url from a subreddit of your choosing')
.version('2.2')
.option('-s, --subreddit <subreddit>', 'The subreddit to search', 'rabbits')
.option('-j, --json', 'Output as JSON');
.option('-s, --subreddit <subreddit>', 'The subreddit to search', 'rabbits');
program.parse();
@ -22,12 +21,6 @@ randomBunny(options.subreddit)
const result = response.Result!;
const outputLines: string[] = [];
if (options.json) {
console.log(JSON.stringify(result));
return;
}
outputLines.push(`Archived = ${result.Archived}`);
outputLines.push(`Downvotes = ${result.Downs}`);
outputLines.push(`Hidden = ${result.Hidden}`);

View file

@ -1,4 +1,3 @@
export default interface ICliOptions {
subreddit: string,
json?: boolean,
}

View file

@ -88,25 +88,7 @@ describe('subreddit', () => {
expect(subreddit).toBe('Horses');
}, 5000);
});
describe('json', () => {
test('GIVEN -j is supplied, EXPECT output to be valid JSON', async () => {
const result = await cli(['-j'], '.');
const json = JSON.parse(result.stdout);
expect(json).toBeDefined();
}, 5000);
test('GIVEN --json is supplied, EXPECT output to be valid JSON', async () => {
const result = await cli(['--json'], '.');
const json = JSON.parse(result.stdout);
expect(json).toBeDefined();
}, 5000);
});
})
function cli(args: string[], cwd: string): Promise<cliResult> {
return new Promise(resolve => {