-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathis_object.test.ts
More file actions
42 lines (38 loc) · 825 Bytes
/
is_object.test.ts
File metadata and controls
42 lines (38 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { assert, assertFalse, AssertionError, assertThrows } from "@std/assert";
import { assertIsObject, isObject } from "./is_object.ts";
const VALID = [
{},
{ a: 1 },
{ 1: "a" },
{ [Symbol.dispose]: "" },
];
const INVALID = [
"",
1,
undefined,
null,
[],
[""],
new Map(),
];
Deno.test("isObject > can detect records", () => {
for (const v of VALID) {
assert(isObject(v), `Value of '${v}' is not valid`);
}
for (const v of INVALID) {
assertFalse(isObject(v), `Value of '${v}' is not invalid`);
}
});
Deno.test("assertIsObject > can detect records", () => {
for (const v of VALID) {
assertIsObject(v);
}
for (const v of INVALID) {
assertThrows(
() => assertIsObject(v),
AssertionError,
undefined,
`Value of '${v}' did not throw`,
);
}
});