Update isObject and isIterable, isArray
Some checks failed
JavaScriptUtilsVitest / ci-tests (push) Has been cancelled
Some checks failed
JavaScriptUtilsVitest / ci-tests (push) Has been cancelled
isObject only returns true for objects and nothing else. Update cel/ael in the HTML builder to use isArray for array check
This commit is contained in:
@@ -5,6 +5,8 @@ import {
|
||||
// isFunction,
|
||||
// executeFunctionByName,
|
||||
isObject,
|
||||
isArray,
|
||||
isIterable,
|
||||
getObjectCount,
|
||||
keyInObject,
|
||||
objectKeyExists,
|
||||
@@ -30,15 +32,57 @@ describe("isObject", () => {
|
||||
let is_object = {
|
||||
"a": 1
|
||||
};
|
||||
let empty_array = [];
|
||||
let is_array = [1, 2, 3];
|
||||
let is_string = "";
|
||||
let is_number = 1;
|
||||
expect(isObject(empty_object)).toEqual(true);
|
||||
expect(isObject(is_object)).toEqual(true);
|
||||
expect(isObject(empty_array)).toEqual(false);
|
||||
expect(isObject(is_array)).toEqual(false);
|
||||
expect(isObject(is_string)).toEqual(false);
|
||||
expect(isObject(is_number)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isArray", () => {
|
||||
it('should return bool if array', () => {
|
||||
let empty_object = {};
|
||||
let is_object = {
|
||||
"a": 1
|
||||
};
|
||||
let empty_array = [];
|
||||
let is_array = [1, 2, 3];
|
||||
let is_string = "";
|
||||
let is_number = 1;
|
||||
expect(isArray(empty_object)).toEqual(false);
|
||||
expect(isArray(is_object)).toEqual(false);
|
||||
expect(isArray(empty_array)).toEqual(true);
|
||||
expect(isArray(is_array)).toEqual(true);
|
||||
expect(isArray(is_string)).toEqual(false);
|
||||
expect(isArray(is_number)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isIterable", () => {
|
||||
it('should return bool if iterable', () => {
|
||||
let empty_object = {};
|
||||
let is_object = {
|
||||
"a": 1
|
||||
};
|
||||
let empty_array = [];
|
||||
let is_array = [1, 2, 3];
|
||||
let is_string = "";
|
||||
let is_number = 1;
|
||||
expect(isIterable(empty_object)).toEqual(true);
|
||||
expect(isIterable(is_object)).toEqual(true);
|
||||
expect(isIterable(empty_array)).toEqual(true);
|
||||
expect(isIterable(is_array)).toEqual(true);
|
||||
expect(isIterable(is_string)).toEqual(false);
|
||||
expect(isIterable(is_number)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getObjectCount", () => {
|
||||
it('should return count of objects', () => {
|
||||
let zero = {};
|
||||
|
||||
Reference in New Issue
Block a user