Unit Test Utils: iconHashToBigInt iconBigIntToHash

This commit is contained in:
lts372005
2021-10-30 09:34:09 +07:00
parent 87c20b01f0
commit 39ae1ccd9d
2 changed files with 31 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
import "./local/snowflake.ts";
import "./util/validateLength.ts";
import "./util/hasProperty.ts";
import "./util/hash.ts";

30
tests/util/hash.ts Normal file
View File

@@ -0,0 +1,30 @@
import { iconHashToBigInt, iconBigintToHash } from "../../src/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);
},
});