mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix: add more utils unit tests
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import { bigintToSnowflake, snowflakeToBigint } from "../../util/bigint.ts";
|
||||
import { assertEquals, assertNotEquals } from "../deps.ts";
|
||||
|
||||
Deno.test("[Local Test] - snowflakeToBigint ", () => {
|
||||
const text = "130136895395987456";
|
||||
const big = 130136895395987456n;
|
||||
const result = snowflakeToBigint(text);
|
||||
|
||||
assertEquals(big, result);
|
||||
assertNotEquals(text, result);
|
||||
});
|
||||
|
||||
Deno.test("[Local Test] - bigIntToSnowflake", () => {
|
||||
const text = "130136895395987456";
|
||||
const big = 130136895395987456n;
|
||||
const result = bigintToSnowflake(big);
|
||||
|
||||
assertEquals(text, result);
|
||||
assertNotEquals(big, result);
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
import { iconBigintToHash, iconHashToBigInt } from "../../util/hash.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
const iconHash = "4bbb271a13f7195031adcc06a2d867ce";
|
||||
const iconBigInt = 3843769888406823508519992434416504301518n;
|
||||
const a_iconHash = "a_4bbb271a13f7195031adcc06a2d867ce";
|
||||
const a_iconBigInt = 3503487521485885045056617826984736090062n;
|
||||
Deno.test({
|
||||
name: "[utils] icon hash to bigint",
|
||||
fn() {
|
||||
assertEquals(iconHashToBigInt(iconHash), iconBigInt);
|
||||
},
|
||||
});
|
||||
Deno.test({
|
||||
name: "[utils] icon bigint to hash",
|
||||
fn() {
|
||||
assertEquals(iconBigintToHash(iconBigInt), iconHash);
|
||||
},
|
||||
});
|
||||
Deno.test({
|
||||
name: "[utils] icon hash to bigint a_ (animated)",
|
||||
fn() {
|
||||
assertEquals(iconHashToBigInt(a_iconHash), a_iconBigInt);
|
||||
},
|
||||
});
|
||||
Deno.test({
|
||||
name: "[utils] icon bigint to hash a_ (animated)",
|
||||
fn() {
|
||||
assertEquals(iconBigintToHash(a_iconBigInt), a_iconHash);
|
||||
},
|
||||
});
|
||||
+1
-9
@@ -19,12 +19,4 @@ Deno.test({
|
||||
|
||||
// delay
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] delay 2000 ms",
|
||||
async fn() {
|
||||
const before = Date.now();
|
||||
await delay(2000);
|
||||
const after = Date.now();
|
||||
assertEquals(after - before >= 2000, true);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import { validateLength } from "../../util/validateLength.ts";
|
||||
import { assertEquals } from "../deps.ts";
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is too low",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { min: 5 }), false);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is too high",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { max: 3 }), false);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is NOT just right in between.",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { min: 5, max: 3 }), false);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is NOT too low",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { min: 3 }), true);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is NOT too high",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { max: 5 }), true);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "[utils] Validate length is just right in between.",
|
||||
fn() {
|
||||
assertEquals(validateLength("test", { min: 3, max: 6 }), true);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user