fix embeds

This commit is contained in:
Skillz4Killz
2021-10-28 17:22:00 +00:00
committed by GitHub
parent 78e3443c7f
commit 109c2b8abe
5 changed files with 101 additions and 149 deletions
-20
View File
@@ -1,20 +0,0 @@
// // THE ORDER OF THE IMPORTS IN THIS FILE MATTER!
// // DO NOT MOVE THEM UNLESS YOU KNOW WHAT YOUR DOING!
// import "./util/utils.ts";
// import "./util/validate_length.ts";
// import "./util/loop_object.ts";
// // Final cleanup
// import { delay } from "../src/util/utils.ts";
// if (import.meta.main) {
// // clear all the sweeper intervals
// for (const c of Object.values(cache)) {
// if (!(c instanceof Map)) continue;
// console.log("Cleaned");
// }
// await delay(3000);
// }
-54
View File
@@ -1,54 +0,0 @@
import { loopObject } from "../../src/util/loop_object.ts";
import { assertEquals } from "../deps.ts";
const objWithBigints = {
a: BigInt(0),
b: "string",
c: 123,
d: [123],
e: {
f: 123,
g: BigInt(2),
},
h: null,
i: undefined,
j: 0,
// k: function () {
// return true;
// },
};
const correctlyConverted = {
a: "0",
b: "string",
c: 123,
d: [123],
e: {
f: 123,
g: "2",
},
h: null,
i: undefined,
j: 0,
// k: function () {
// return true;
// },
};
Deno.test({
name: "[utils] loop over an object with a handler",
fn() {
const converted = loopObject(
objWithBigints,
(value) =>
typeof value === "bigint"
? value.toString()
: Array.isArray(value)
? value.map((v) => (typeof v === "bigint" ? v.toString() : v))
: value,
`Running for loop in unit test function for changing bigints to strings.`
);
assertEquals(converted, correctlyConverted);
},
});
+2 -73
View File
@@ -1,79 +1,8 @@
import { ApplicationCommandOption } from "../../src/types/interactions/commands/application_command_option.ts";
import { ApplicationCommandOptionChoice } from "../../src/types/interactions/commands/application_command_option_choice.ts";
import { DiscordApplicationCommandOptionTypes } from "../../src/types/interactions/commands/application_command_option_types.ts";
import { camelize, snakelize, validateSlashCommands } from "../../src/util/utils.ts";
import { assertEquals, assertThrows } from "../deps.ts";
const testSnakeObject = {
// deno-lint-ignore camelcase
hello_world: "hello_world",
// deno-lint-ignore camelcase
the_universe: {
blue_planet: {
water: "is_blue",
dirt: "isDirty",
},
moon: {
earth_moon: {
is_round: true,
},
other_moon: {
is_round: 0,
},
},
arrays: ["one_two", { moo_cow: { boo: true } }],
test_the_id: "123123123123",
},
};
const testCamelObject = {
helloWorld: "hello_world",
theUniverse: {
bluePlanet: {
water: "is_blue",
dirt: "isDirty",
},
moon: {
earthMoon: {
isRound: true,
},
otherMoon: {
isRound: 0,
},
},
arrays: ["one_two", { mooCow: { boo: true } }],
testTheId: "123123123123",
},
};
const someOther = {
helloWorld: 1,
};
const someElseOther = {
// deno-lint-ignore camelcase
hello_world: 1,
};
Deno.test({
name: "[utils] convert snake case keys to camel case",
fn() {
const result = camelize(testSnakeObject);
assertEquals(result, testCamelObject);
const resultTwo = camelize(someOther);
assertEquals(resultTwo, someOther);
},
});
Deno.test({
name: "[utils] convert camel case keys to snake case",
fn() {
const result = snakelize(testCamelObject);
assertEquals(result, testSnakeObject);
const resultTwo = snakelize(someElseOther);
assertEquals(resultTwo, someElseOther);
},
});
import { validateSlashCommands } from "../../src/util/utils.ts";
import { assertThrows } from "../deps.ts";
Deno.test({
name: "[utils] validateSlashCommands(): application command name",