From 6b5344b9b5f71c5700daebf334b47f31e9c0f4d3 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 29 Oct 2021 20:48:57 +0000 Subject: [PATCH] add snowflake unit tests --- tests/deps.ts | 1 + tests/local/snowflake.ts | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/deps.ts b/tests/deps.ts index 6c7cb054d..da1c2c2ba 100644 --- a/tests/deps.ts +++ b/tests/deps.ts @@ -2,5 +2,6 @@ export { assertArrayIncludes, assertEquals, assertExists, + assertNotEquals, assertThrows, } from "https://deno.land/std@0.113.0/testing/asserts.ts"; diff --git a/tests/local/snowflake.ts b/tests/local/snowflake.ts index 8fea36b27..93160cb14 100644 --- a/tests/local/snowflake.ts +++ b/tests/local/snowflake.ts @@ -1,9 +1,20 @@ -import { snowflakeToBigint } from "../../src/util/bigint.ts"; -import { assertEquals } from "../deps.ts"; +import { bigintToSnowflake, snowflakeToBigint } from "../../src/util/bigint.ts"; +import { assertEquals, assertNotEquals } from "../deps.ts"; -Deno.test("[Local Test] - snowflakeToBigint ", async (t) => { +Deno.test("[Local Test] - snowflakeToBigint ", () => { const text = "130136895395987456"; const big = 130136895395987456n; + const result = snowflakeToBigint(text); - assertEquals(big, 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); });