From 9fc0eb321574c6905a09b9af364709ee3d71641e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 8 Jan 2024 13:12:16 +0000 Subject: [PATCH 1/4] Update dependency @types/node to v20.10.7 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 46c61c8..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.10.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.3.tgz#4900adcc7fc189d5af5bb41da8f543cea6962030" - integrity sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg== + 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" From bc4f024619ff6d3d9281af4903570fb8039d4ee7 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Tue, 9 Jan 2024 19:00:52 +0000 Subject: [PATCH 2/4] Fix tests (#136) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. #125 ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/136 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- tests/cli.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cli.test.ts b/tests/cli.test.ts index aa68d3b..1b04e47 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', 'horses'], '.'); + const result = await cli(['-s', 'pics'], '.'); const subreddit = result.stdout.split('\n') .find(x => x && x.length > 0 && x.split(' = ')[0] == 'Subreddit')! .split(' = ')[1]; - expect(subreddit).toBe('Horses'); + expect(subreddit).toBe('pics'); }, 5000); test('GIVEN --subreddit is supplied, EXPECT subreddit to be changed', async () => { - const result = await cli(['--subreddit', 'horses'], '.'); + const result = await cli(['--subreddit', 'pics'], '.'); const subreddit = result.stdout.split('\n') .find(x => x && x.length > 0 && x.split(' = ')[0] == 'Subreddit')! .split(' = ')[1]; - expect(subreddit).toBe('Horses'); + expect(subreddit).toBe('pics'); }, 5000); }); describe('sort', () => { - test('GIVEN --sort is not supplird, EXPECT sort to be defaulted', async () => { + test('GIVEN --sort is not supplied, EXPECT sort to be defaulted', async () => { const result = await cli(['-q'], '.'); const sortBy = result.stdout.split('\n') From 5ea8b72e5431160b9bc41708538d7c5330579665 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 12 Jan 2024 17:48:37 +0000 Subject: [PATCH 3/4] Add higher limit on json (#139) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Add higher limit on the json result - This will fix the tests not always fetching an image from r/rabbits, as not every post in the top is a single image #125 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/139 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/index.ts | 2 +- tests/index.test.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 29f8ecf..3d7277b 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`) + const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json?limit=100`) .then((res) => { return res; }) diff --git a/tests/index.test.ts b/tests/index.test.ts index 302fd1d..37ab315 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/hot.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); }); 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'); + expect(fetchMock).toBeCalledWith('https://reddit.com/r/rabbits/new.json?limit=100'); }); }); \ No newline at end of file From 9bb8b6c23cd8f3f88fa8ea0dbb916e1382375139 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 15 Jan 2024 00:02:25 +0000 Subject: [PATCH 4/4] Update dependency @types/node to v20.11.0 --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 46c61c8..40774c8 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.10.3" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.3.tgz#4900adcc7fc189d5af5bb41da8f543cea6962030" - integrity sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg== + version "20.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.0.tgz#8e0b99e70c0c1ade1a86c4a282f7b7ef87c9552f" + integrity sha512-o9bjXmDNcF7GbM4CNQpmi+TutCgap/K3w1JyKgxAjqx41zp9qlIAVFi0IhCNsJcXolEqLWhbFbEeL0PvYm4pcQ== dependencies: undici-types "~5.26.4"