Archived
1
0
Fork 0
This repository has been archived on 2024-07-25. You can view files and clone it, but cannot push or open issues or pull requests.
paren/core/utils.test.ts

52 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2022-05-22 00:03:48 +03:00
import { assertEquals } from "testing/asserts.ts";
2022-05-22 00:13:39 +03:00
import { concat, isNil, isSkip, join } from "./utils.ts";
2022-05-22 00:03:48 +03:00
Deno.test({
name: "should check value on nil",
fn: () => {
assertEquals(isNil(null), true);
assertEquals(isNil(undefined), true);
assertEquals(isNil(0), false);
assertEquals(isNil(""), false);
assertEquals(isNil(false), false);
assertEquals(isNil({}), false);
assertEquals(isNil([]), false);
},
});
Deno.test({
name: "should check value on skip",
fn: () => {
assertEquals(isSkip(null), true);
assertEquals(isSkip(undefined), true);
assertEquals(isSkip(0), false);
assertEquals(isSkip(""), false);
assertEquals(isSkip(false), true);
assertEquals(isSkip({}), false);
assertEquals(isSkip([]), false);
},
});
2022-05-22 00:13:39 +03:00
Deno.test({
name: "should return joined array",
fn: () => {
assertEquals(join(" ", ["hello", "world"]), "hello world");
assertEquals(
join(" ", ["hello", "", null, undefined, false, "world"]),
"hello world",
);
},
});
Deno.test({
name: "should return concated array",
fn: () => {
assertEquals(concat(["hello", "world"]), "helloworld");
assertEquals(
concat(["hello", "", null, undefined, false, "world"]),
"helloworld",
);
},
});