forked from rjsf-team/react-jsonschema-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isObject.test.ts
31 lines (28 loc) · 960 Bytes
/
isObject.test.ts
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
import { isObject } from "../src";
const NON_OBJECTS = ["string", 10, NaN, true, null, undefined];
const OBJECTS = [{ plain: "object" }, new Object(), new Map()];
describe("isObject()", () => {
it("returns false when a non-object is provided", () => {
NON_OBJECTS.forEach(
(nonObject: string | number | boolean | null | undefined) => {
expect(isObject(nonObject)).toBe(false);
}
);
});
it("returns false when a File is provided", () => {
const file = new File(["test"], "test.txt");
expect(isObject(file)).toBe(false);
});
it("returns false when a Date is provided", () => {
const date = new Date();
expect(isObject(date)).toBe(false);
});
it("returns false when an array is provided", () => {
expect(isObject(["foo"])).toBe(false);
});
it("returns true when an object is provided", () => {
OBJECTS.forEach((object: any) => {
expect(isObject(object)).toBe(true);
});
});
});