test: delundefprop

This commit is contained in:
zkldi
2024-07-01 01:48:27 +01:00
parent 84792fdd80
commit ea49e37d24
+30 -1
View File
@@ -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"));