diff --git a/src/plugins/rule34/api.ts b/src/plugins/rule34/api.ts index 62b2c94..a04c53a 100755 --- a/src/plugins/rule34/api.ts +++ b/src/plugins/rule34/api.ts @@ -1,3 +1,5 @@ +import { assert } from "@std/assert/assert"; + type APIResponse = Array<{ preview_url: string; sample_url: string; @@ -82,3 +84,13 @@ export async function drop5() { } return tmp; } + + +//test refresh here because local stack is not given to other functions +Deno.test("Test Image-Stack refresh", async() => { + await refresh() + const previousStack = [...hyperlinkarray] + await new Promise(r => setTimeout(r, 10000)); + await refresh() + assert(previousStack.length <= hyperlinkarray.length, "Stack-size did not increase as expected!") +}) \ No newline at end of file diff --git a/src/plugins/rule34/messages.ts b/src/plugins/rule34/messages.ts index a149642..a258184 100644 --- a/src/plugins/rule34/messages.ts +++ b/src/plugins/rule34/messages.ts @@ -1,5 +1,5 @@ import { Bot, Message } from "npm:discordeno@18.0.1"; -import { drop5, r34test, refresh } from "./api.ts"; +import { drop5, drop, refresh } from "./api.ts"; import { logMessage } from "@root/logging.ts"; import { defaultString } from "@root/defaultString.ts"; @@ -13,7 +13,7 @@ export async function rule34MessageHandler(bot: Bot, message: Message) { message.guildId === undefined ) { bot.helpers.sendMessage(message.channelId, { - content: defaultString(await r34test()), + content: defaultString(await drop()), }); } break; diff --git a/src/plugins/rule34/test.ts b/src/plugins/rule34/test.ts new file mode 100644 index 0000000..e082453 --- /dev/null +++ b/src/plugins/rule34/test.ts @@ -0,0 +1,8 @@ +import { assert } from "jsr:@std/assert" +import {refresh, drop} from "@root/plugins/rule34/api.ts" + +Deno.test("Test Drop", async() => { + await refresh() + const link = await drop() + assert(link !== "", "Empty String was dropped!") +}) \ No newline at end of file