added tests for rule34 (non sufficient)

This commit is contained in:
fzzinchemical
2025-03-27 15:10:31 +01:00
parent f97bfb03bd
commit eb6dca5368
3 changed files with 22 additions and 2 deletions

View File

@@ -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!")
})

View File

@@ -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;

View File

@@ -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!")
})