1 import {Utils} from "./utils";
2 import each from "jest-each";
5 describe('Util', () => {
7 test('hasContents should return false if object is undefined or null or empty', () => {
8 expect(Utils.hasContents(undefined)).toBeFalsy();
9 expect(Utils.hasContents(null)).toBeFalsy();
10 expect(Utils.hasContents("")).toBeFalsy();
13 test('hasContents should return true if object is not undefined and not null and not empty', () => {
14 expect(Utils.hasContents("someValue")).toBeTruthy();
17 const instantiationTypesDataProvider = [
20 ['ClientConfig', true],
23 each(instantiationTypesDataProvider).test('instantiationType %s isALaCarte shall be %s', (instantiationType, expected ) => {
24 expect(Utils.isALaCarte(instantiationType)).toEqual(expected);
28 ["empty properties, empty flags",{}, {}, 1],
29 ["null properties, undefined flags",null, undefined, 1],
30 ["max_instances 3, flag is on", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
31 ["max_instances 3, flag is off", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: false}, 3],
32 ["null properties, flag is on", null, {FLAG_2002_UNLIMITED_MAX: true}, null],
33 ["null properties, flag is off", null, {FLAG_2002_UNLIMITED_MAX: false}, 1],
34 ["undefined properties, flag is off", undefined, {FLAG_2002_UNLIMITED_MAX: false}, 1],
35 ]).test('getMaxFirstLevel %s', (desc, properties, flags, expected) => {
36 expect(Utils.getMaxFirstLevel(properties, flags)).toEqual(expected);
40 ["empty properties, empty flags",{}, {}, 1],
41 ["null properties, undefined flags",null, undefined, 1],
42 ["wrong field, flag is on", {max_instances:3}, {FLAG_2002_UNLIMITED_MAX: true}, null],
43 ["maxCountInstances 3, flag is on", {maxCountInstances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
44 ["maxCountInstances 3, flag is off", {maxCountInstances:3}, {FLAG_2002_UNLIMITED_MAX: true}, 3],
45 ]).test('getMaxFirstLevel %s', (desc, properties, flags, expected) => {
46 expect(Utils.getMaxVfModule(properties, flags)).toEqual(expected);