add discovery tests

This commit is contained in:
Skillz4Killz
2021-11-03 15:47:45 +00:00
committed by GitHub
parent e719a07107
commit 2a83d8e597
2 changed files with 36 additions and 7 deletions
+14
View File
@@ -0,0 +1,14 @@
import { Bot } from "../../../src/bot.ts";
import { assertEquals } from "../../deps.ts";
export async function getDiscoveryCategoriesTest(bot: Bot, t: Deno.TestContext) {
const categories = await bot.helpers.getDiscoveryCategories();
assertEquals(categories.size > 0, true);
}
export async function validDiscoveryTermTest(bot: Bot, t: Deno.TestContext) {
const valid = await bot.helpers.validDiscoveryTerm("Bots");
assertEquals(valid, true);
}
+22 -7
View File
@@ -55,6 +55,7 @@ import { getBanTests } from "./helpers/guilds/getBan.ts";
import { getBansTests } from "./helpers/guilds/getBans.ts";
import { getGuildTests } from "./helpers/guilds/getGuild.ts";
import { getVanityURLTests } from "./helpers/guilds/getVanityUrl.ts";
import { getDiscoveryCategoriesTest, validDiscoveryTermTest } from "./helpers/misc/discoveries.ts";
// CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS
const sanitizeMode = {
@@ -765,7 +766,7 @@ Deno.test({
}),
]);
},
});
});
// SOME MISC TESTS
await Promise.all([
@@ -775,23 +776,37 @@ Deno.test({
await getUserTests(bot, t);
},
...sanitizeMode,
}),t.step({
}),
t.step({
name: "[tranform] snowflake to bigint",
fn: async (t) => {
assertEquals(130136895395987456n, bot.transformers.snowflake("130136895395987456"));
},
...sanitizeMode
...sanitizeMode,
}),
// CONDUCT MEMORY BENCHMARK TESTS
t.step({
name: "[discovery] Validate a discovery search term",
fn: async (t) => {
await validDiscoveryTermTest(bot, t);
},
...sanitizeMode,
}),
t.step({
name: "[discovery] get categories from discovery",
fn: async (t) => {
await getDiscoveryCategoriesTest(bot, t);
},
...sanitizeMode,
}),
// CONDUCT MEMORY BENCHMARK TESTS
await t.step({
name: "[Memory] Benchmark memory tests",
fn: async (t) => {
await memoryBenchmarks(bot, true);
},
})
])
}),
]);
await stopBot(bot);
},