From ea49e37d24b54114f8b2fc1257dcf53dea367ef6 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Mon, 1 Jul 2024 01:48:25 +0100 Subject: [PATCH] test: delundefprop --- server/src/utils/misc.test.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/server/src/utils/misc.test.ts b/server/src/utils/misc.test.ts index 250c62630..05d5d2cf5 100644 --- a/server/src/utils/misc.test.ts +++ b/server/src/utils/misc.test.ts @@ -1,4 +1,9 @@ -import { GetMillisecondsSince, IsValidURL, RoundToNDecimalPlaces } from "./misc"; +import { + DeleteUndefinedProps, + GetMillisecondsSince, + IsValidURL, + RoundToNDecimalPlaces, +} from "./misc"; import t from "tap"; t.test("#GetMillisecondsSince", (t) => { @@ -9,6 +14,30 @@ t.test("#GetMillisecondsSince", (t) => { t.end(); }); +t.test("#DeleteUndefinedProps", (t) => { + const v = { + a: 1, + b: 2, + c: undefined, + d: { + e: 3, + f: undefined, + }, + }; + + DeleteUndefinedProps(v); + + t.strictSame(v, { + a: 1, + b: 2, + d: { + e: 3, + }, + }); + + t.end(); +}); + t.test("#IsValidURL", (t) => { t.ok(IsValidURL("https://example.com")); t.ok(IsValidURL("http://example.com"));