Fix gallery not finding any images if there is more than one image #259

Open
Vylpes wants to merge 1 commit from feature/257-gallery-image-undefined into develop
2 changed files with 2 additions and 2 deletions

View file

@ -96,7 +96,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho
let gallery: string[];
if (randomData.url.includes("/gallery")) {
const galleryImage = await ImageHelper.FetchImageFromRedditGallery(randomData.url);
const galleryImage = await ImageHelper.FetchImageFromRedditGallery(`https://reddit.com${randomData.permalink}`);
if (!galleryImage) {
return {

View file

@ -202,7 +202,7 @@ describe('randomBunny', () => {
expect(fetchMock).toHaveBeenCalledWith('https://reddit.com/r/rabbits/new.json?limit=100');
expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledTimes(1);
expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledWith("https://i.redd.it/gallery/cr8xudsnkgua1");
expect(ImageHelper.FetchImageFromRedditGallery).toHaveBeenCalledWith("https://reddit.com/r/Rabbits/comments/12pa5te/someone_told_pickles_its_monday_internal_fury/");
});
test("GIVEN data fetched is a gallery AND an image is not returned from the helper, EXPECT error", async () => {