added tests for rule34 (non sufficient)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { assert } from "@std/assert/assert";
|
||||||
|
|
||||||
type APIResponse = Array<{
|
type APIResponse = Array<{
|
||||||
preview_url: string;
|
preview_url: string;
|
||||||
sample_url: string;
|
sample_url: string;
|
||||||
@@ -82,3 +84,13 @@ export async function drop5() {
|
|||||||
}
|
}
|
||||||
return tmp;
|
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!")
|
||||||
|
})
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Bot, Message } from "npm:discordeno@18.0.1";
|
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 { logMessage } from "@root/logging.ts";
|
||||||
import { defaultString } from "@root/defaultString.ts";
|
import { defaultString } from "@root/defaultString.ts";
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ export async function rule34MessageHandler(bot: Bot, message: Message) {
|
|||||||
message.guildId === undefined
|
message.guildId === undefined
|
||||||
) {
|
) {
|
||||||
bot.helpers.sendMessage(message.channelId, {
|
bot.helpers.sendMessage(message.channelId, {
|
||||||
content: defaultString(await r34test()),
|
content: defaultString(await drop()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
8
src/plugins/rule34/test.ts
Normal file
8
src/plugins/rule34/test.ts
Normal 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!")
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user