diff --git a/src/index.ts b/src/index.ts index 3d7277b..29f8ecf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ const sortable = [ export default async function randomBunny(subreddit: string, sortBy: string = 'hot'): Promise { if (!sortable.includes(sortBy)) sortBy = 'hot'; - const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json?limit=100`) + const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`) .then((res) => { return res; }) diff --git a/tests/cli.test.ts b/tests/cli.test.ts index 1b04e47..aa68d3b 100644 --- a/tests/cli.test.ts +++ b/tests/cli.test.ts @@ -70,28 +70,28 @@ describe('subreddit', () => { }, 5000); test('GIVEN -s is supplied, EXPECT subreddit to be changed', async () => { - const result = await cli(['-s', 'pics'], '.'); + const result = await cli(['-s', 'horses'], '.'); const subreddit = result.stdout.split('\n') .find(x => x && x.length > 0 && x.split(' = ')[0] == 'Subreddit')! .split(' = ')[1]; - expect(subreddit).toBe('pics'); + expect(subreddit).toBe('Horses'); }, 5000); test('GIVEN --subreddit is supplied, EXPECT subreddit to be changed', async () => { - const result = await cli(['--subreddit', 'pics'], '.'); + const result = await cli(['--subreddit', 'horses'], '.'); const subreddit = result.stdout.split('\n') .find(x => x && x.length > 0 && x.split(' = ')[0] == 'Subreddit')! .split(' = ')[1]; - expect(subreddit).toBe('pics'); + expect(subreddit).toBe('Horses'); }, 5000); }); describe('sort', () => { - test('GIVEN --sort is not supplied, EXPECT sort to be defaulted', async () => { + test('GIVEN --sort is not supplird, EXPECT sort to be defaulted', async () => { const result = await cli(['-q'], '.'); const sortBy = result.stdout.split('\n') diff --git a/tests/index.test.ts b/tests/index.test.ts index 37ab315..302fd1d 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -36,7 +36,7 @@ describe('randomBunny', () => { expect(result.Result).toBeDefined(); expect(result.Error).toBeUndefined(); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json'); }); test('GIVEN sortBy is NOT supplied, expect it to default to hot', async () => { @@ -68,7 +68,7 @@ describe('randomBunny', () => { expect(result.Result).toBeDefined(); expect(result.Error).toBeUndefined(); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json'); }); test('GIVEN sortBy is NOT valid, expect it to default to hot', async () => { @@ -100,7 +100,7 @@ describe('randomBunny', () => { expect(result.Result).toBeDefined(); expect(result.Error).toBeUndefined(); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json'); }); test('GIVEN the fetch fails, EXPECT failure result', async () => { @@ -115,7 +115,7 @@ describe('randomBunny', () => { expect(result.Error!.Code).toBe(ErrorCode.FailedToFetchReddit); expect(result.Error!.Message).toBe(ErrorMessages.FailedToFetchReddit); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json'); }); test('GIVEN the result is NOT valid JSON, EXPECT failure result', async () => { @@ -132,7 +132,7 @@ describe('randomBunny', () => { expect(result.Error!.Code).toBe(ErrorCode.UnableToParseJSON); expect(result.Error!.Message).toBe(ErrorMessages.UnableToParseJSON); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json'); }); test('GIVEN randomSelect does NOT find a response, EXPECT failure result', async () => { @@ -153,7 +153,7 @@ describe('randomBunny', () => { expect(result.Error!.Code).toBe(ErrorCode.NoImageResultsFound); expect(result.Error!.Message).toBe(ErrorMessages.NoImageResultsFound); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json'); }); test('GIVEN randomSelect does NOT find a valid response, EXPECT failure result', async () => { @@ -188,6 +188,6 @@ describe('randomBunny', () => { expect(result.Error!.Code).toBe(ErrorCode.NoImageResultsFound); expect(result.Error!.Message).toBe(ErrorMessages.NoImageResultsFound); - expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json'); }); }); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 40774c8..9eeb239 100644 --- a/yarn.lock +++ b/yarn.lock @@ -863,9 +863,9 @@ integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/node@*", "@types/node@^20.0.0": - version "20.11.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.0.tgz#8e0b99e70c0c1ade1a86c4a282f7b7ef87c9552f" - integrity sha512-o9bjXmDNcF7GbM4CNQpmi+TutCgap/K3w1JyKgxAjqx41zp9qlIAVFi0IhCNsJcXolEqLWhbFbEeL0PvYm4pcQ== + version "20.10.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.7.tgz#40fe8faf25418a75de9fe68a8775546732a3a901" + integrity sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg== dependencies: undici-types "~5.26.4"