diff --git a/docs/cli.md b/docs/cli.md index 774398e..7eb2858 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -25,6 +25,7 @@ By default, the command will fetch a random image from `r/rabbits` and return it $ random-bunny Archived = false +Author = Rabbit_Owner Downvotes = 0 Hidden = false Permalink = /r/Rabbits/comments/1av1rg9/cute_baby_bun/ @@ -72,7 +73,7 @@ $ random-bunny --json $ randon-bunny -j -{"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"} +{"Archived":false,"Author":"Rabbit_Owner","Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"} ``` ## Sort diff --git a/readme.md b/readme.md index 9d9dc9d..e7ba49c 100644 --- a/readme.md +++ b/readme.md @@ -37,6 +37,7 @@ Returns a `json string` for a random post. Accepts 3 arguments: `subreddit`, `so The json string which gets returned consists of: - archived +- author - downs - hidden - permalink diff --git a/src/contracts/IFetchResult.ts b/src/contracts/IFetchResult.ts index 578bbea..dc5385f 100644 --- a/src/contracts/IFetchResult.ts +++ b/src/contracts/IFetchResult.ts @@ -1,6 +1,7 @@ export default interface IFetchResult { data: { archived: boolean, + author: string, downs: number, hidden: boolean, permalink: string, diff --git a/src/contracts/IRedditResult.ts b/src/contracts/IRedditResult.ts index 84e726c..13fef75 100644 --- a/src/contracts/IRedditResult.ts +++ b/src/contracts/IRedditResult.ts @@ -1,5 +1,6 @@ export default interface IRedditResult { Archived: boolean, + Author: string, Downs: number, Hidden: boolean, Permalink: string, diff --git a/src/helpers/outputHelper.ts b/src/helpers/outputHelper.ts index 2e25935..808634d 100644 --- a/src/helpers/outputHelper.ts +++ b/src/helpers/outputHelper.ts @@ -12,6 +12,7 @@ export default class OutputHelper { } outputLines.push(`Archived = ${result.Archived}`); + outputLines.push(`Author = ${result.Author}`); outputLines.push(`Downvotes = ${result.Downs}`); outputLines.push(`Hidden = ${result.Hidden}`); outputLines.push(`Permalink = ${result.Permalink}`); diff --git a/src/index.ts b/src/index.ts index 3e573af..056fe1f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -118,6 +118,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho } const redditResult: IRedditResult = { + Author: randomData['author'], Archived: randomData['archived'], Downs: randomData['downs'], Hidden: randomData['hidden'], diff --git a/tests/helpers/__snapshots__/outputHelper.test.ts.snap b/tests/helpers/__snapshots__/outputHelper.test.ts.snap index 79f386f..39e952e 100644 --- a/tests/helpers/__snapshots__/outputHelper.test.ts.snap +++ b/tests/helpers/__snapshots__/outputHelper.test.ts.snap @@ -2,6 +2,7 @@ exports[`GenerateOutput EXPECT standout output to be returned 1`] = ` "Archived = false +Author = author Downvotes = 0 Hidden = false Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/ @@ -12,10 +13,11 @@ Upvotes = 17 Url = https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d" `; -exports[`GenerateOutput GIVEN options.json is true, EXPECT output to be returned as JSON 1`] = `"{"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/","Subreddit":"Rabbits","SubredditSubscribers":654751,"Title":"This is my Ms Bear!","Ups":17,"Url":"https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"}"`; +exports[`GenerateOutput GIVEN options.json is true, EXPECT output to be returned as JSON 1`] = `"{"Archived":false,"Author":"author","Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/","Subreddit":"Rabbits","SubredditSubscribers":654751,"Title":"This is my Ms Bear!","Ups":17,"Url":"https://preview.redd.it/d5yno653zf7d1.jpg?width=640&crop=smart&auto=webp&s=5064d1caec3c12ac2855eb57ff131d0b313d5e9d"}"`; exports[`GenerateOutput GIVEN options.queryMetadata is supplied, EXPECT query metadata to be added 1`] = ` "Archived = false +Author = author Downvotes = 0 Hidden = false Permalink = /r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/ diff --git a/tests/helpers/outputHelper.test.ts b/tests/helpers/outputHelper.test.ts index a0f1959..5e90dc8 100644 --- a/tests/helpers/outputHelper.test.ts +++ b/tests/helpers/outputHelper.test.ts @@ -14,6 +14,7 @@ describe("GenerateOutput", () => { }, Result: { Archived: false, + Author: 'author', Downs: 0, Hidden: false, Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/", @@ -45,6 +46,7 @@ describe("GenerateOutput", () => { }, Result: { Archived: false, + Author: 'author', Downs: 0, Hidden: false, Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/", @@ -78,6 +80,7 @@ describe("GenerateOutput", () => { }, Result: { Archived: false, + Author: 'author', Downs: 0, Hidden: false, Permalink: "/r/Rabbits/comments/1dj8pbt/this_is_my_ms_bear/", diff --git a/tests/index.test.ts b/tests/index.test.ts index f70d411..8e49ffd 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -20,6 +20,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -52,6 +53,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -137,6 +139,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -173,6 +176,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -209,6 +213,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -244,6 +249,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -276,6 +282,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/', @@ -311,6 +318,7 @@ describe('randomBunny', () => { { data: { archived: false, + author: 'author', downs: 0, hidden: false, permalink: '/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/',