Update tests
All checks were successful
Test / build (push) Successful in 10s

This commit is contained in:
Ethan Lane 2024-10-25 16:32:52 +01:00
parent 4aac791c75
commit 81437ede41
5 changed files with 22 additions and 17 deletions

View file

@ -2,11 +2,11 @@ import fetch from "got-cjs";
import * as htmlparser from "htmlparser2";
export default class ImageHelper {
public static async FetchImageFromRedditGallery(url: string): Promise<string[] | undefined> {
public static async FetchImageFromRedditGallery(url: string): Promise<string[]> {
const fetched = await fetch(url);
if (!fetched || fetched.errored || fetched.statusCode != 200) {
return undefined;
return [];
}
const dom = htmlparser.parseDocument(fetched.body);

View file

@ -93,7 +93,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho
const randomData = randomSelect.data;
let url: string;
let gallery: string[] = [];
let gallery: string[];
if (randomData.url.includes("/gallery")) {
const galleryImage = await ImageHelper.FetchImageFromRedditGallery(randomData.url);
@ -117,6 +117,7 @@ export default async function randomBunny(subreddit: string, sortBy: "new" | "ho
gallery = galleryImage;
} else {
url = randomData.url;
gallery = [randomData.url];
}
const redditResult: IRedditResult = {