forked from Pythagora-io/pythagora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisJSONObject.test.js
61 lines (50 loc) · 2.2 KB
/
isJSONObject.test.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
describe("isJSONObject", () => {
test("should return true for an empty object", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject({})).toBeTruthy();
});
test("should return true for a non-empty object", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject({ key: "value" })).toBeTruthy();
});
test("should return false for an array", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject([])).toBeFalsy();
});
test("should return false for a string", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject("test string")).toBeFalsy();
});
test("should return false for a number", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(42)).toBeFalsy();
});
test("should return false for a boolean", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(true)).toBeFalsy();
});
test("should return false for null", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(null)).toBeFalsy();
});
test("should return false for undefined", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(undefined)).toBeFalsy();
});
test("should return false for a function", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(() => {})).toBeFalsy();
});
test("should return false for a built-in Error object", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(new Error())).toBeFalsy();
});
test("should return false for a Date object", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(new Date())).toBeFalsy();
});
test("should return false for a RegExp object", () => {
const { isJSONObject } = require("../../../../../src/utils/common.js");
expect(isJSONObject(/test/)).toBeFalsy();
});
});