/** * Created by anaha on 9/27/17. */ describe("Test LayoutConfigurationVO", function() { var layoutConfObj; var notExpandableSectionName = LayoutConfigurationVO.prototype.specialHandlingSections[0], notConfigurableSectionName = 'statusSection'; var layout = { name: 'test', layout: 'row', panels: [ {name: notExpandableSectionName}, {name: 'testSection'}, {name: notConfigurableSectionName}, ] }; it(" should do object creation ", function() { layoutConfObj = new LayoutConfigurationVO(); expect(layoutConfObj instanceof BaseVO).toEqual(true); expect(layoutConfObj instanceof LayoutConfigurationVO).toEqual(true); }); it(" should do object initilization ", function() { var layoutConfProp = layoutConfObj.getProps(); expect(layoutConfProp).toEqual(['id', 'name', 'layout', 'panels']); expect(layoutConfObj.id).toBeDefined(); expect(layoutConfObj.name).toBeDefined(); expect(layoutConfObj.layout).toBeDefined(); expect(layoutConfObj.panels).toBeDefined(); expect(layoutConfObj.id).toEqual(''); expect(layoutConfObj.name).toEqual(''); expect(layoutConfObj.layout).toEqual(''); expect(layoutConfObj.panels).toEqual([]); }); it(' should set flags on not configurable and not expandable layout sections after instance creation', function () { var testLayout = new LayoutConfigurationVO().build(layout); var hasNotExpandableSections = false, hasNotConfigurableSections = false; testLayout.panels.forEach(function (panel) { if (panel.notExpandable) { hasNotExpandableSections = true; } if (panel.notConfigurable) { hasNotConfigurableSections = true; } }); expect(hasNotExpandableSections).toBeTruthy(); expect(hasNotConfigurableSections).toBeTruthy(); }); it(' should strip all helper properties from layout panels', function () { var testLayout = new LayoutConfigurationVO().build(layout), rawLayout = testLayout.getRawLayout(), helperProps = ['notConfigurable', 'notExpandable', 'emptyPanel']; var hasHelperProps = function (screenLayout) { return screenLayout.panels.some(function (panel) { return helperProps.some(function (prop) { return panel.hasOwnProperty(prop); }); }); }; expect(hasHelperProps(testLayout)).toEqual(true); expect(hasHelperProps(rawLayout)).toEqual(false); }); });