141 lines
5.5 KiB
JavaScript
141 lines
5.5 KiB
JavaScript
/**
|
|
* Created by abhatkha on 5/8/17.
|
|
*/
|
|
//This is test suite for baseVO
|
|
|
|
describe("Test ActionVO", function() {
|
|
|
|
var actionObj
|
|
it(" should create object ", function() {
|
|
actionObj = new ActionVO();
|
|
expect(actionObj instanceof BaseVO).toEqual(true);
|
|
expect(actionObj instanceof ActionVO).toEqual(true);
|
|
});
|
|
|
|
it(" should initilize objects with all properties ", function() {
|
|
var actionProp= actionObj.getProps();
|
|
expect(actionProp).toEqual(['id', 'createDate', 'resource', 'actionType', 'actionName', 'supportedPlatforms', 'url', 'labels', 'sequenceNo', 'scope', 'target', 'subActions', 'entryId', 'templateId', 'mappings', 'formName', 'isSynchronous', 'expressions', 'mappedFields', 'mode', 'screenId']);
|
|
|
|
expect(actionObj.id).not.toBeDefined();
|
|
expect(actionObj.createDate).not.toBeDefined();
|
|
|
|
expect(actionObj.resource).toEqual('');
|
|
expect(actionObj.actionType).toEqual('client');
|
|
expect(actionObj.actionName).toEqual('');
|
|
expect(actionObj.screenId).toEqual('');
|
|
expect(actionObj.supportedPlatforms).toEqual(['web']);
|
|
expect(actionObj.supportedPlatforms).not.toEqual([]);
|
|
expect(actionObj.url).toEqual('');
|
|
expect(actionObj.labels).not.toEqual({ });
|
|
expect(actionObj.labels).toEqual({ 'default':'' });
|
|
expect(actionObj.sequenceNo).not.toBeNull();
|
|
expect(actionObj.sequenceNo).toEqual(0);
|
|
expect(actionObj.scope).toEqual({});
|
|
expect(actionObj.subActions).not.toBeDefined();
|
|
expect(actionObj.target).toEqual('new');
|
|
expect(actionObj.mode).toEqual('both');
|
|
expect(actionObj.isOpen).toBeFalsy();
|
|
expect(actionObj.delete).toBeFalsy();
|
|
});
|
|
|
|
it(" openItem functions should set isOpen true ", function() {
|
|
expect(actionObj.isOpen).toBeFalsy();
|
|
actionObj.openItem();
|
|
expect(actionObj.isOpen).toBeTruthy();
|
|
});
|
|
|
|
it(" closeItem functions should set isOpen false ", function() {
|
|
expect(actionObj.isOpen).toBeTruthy();
|
|
actionObj.closeItem();
|
|
expect(actionObj.isOpen).toBeFalsy();
|
|
});
|
|
|
|
it(" deleteItem functions should set delete true ", function() {
|
|
expect(actionObj.delete).toBeFalsy();
|
|
actionObj.deleteItem();
|
|
expect(actionObj.delete).toBeTruthy();
|
|
});
|
|
|
|
it(" setResource functions should set resource ", function() {
|
|
actionObj.setResource('test');
|
|
expect(actionObj.resource).toEqual('test');
|
|
|
|
});
|
|
|
|
it(" setAssetScope functions should set scope ", function() {
|
|
expect(actionObj.scope).toEqual({});
|
|
expect(actionObj.subActions).not.toBeDefined();
|
|
|
|
actionObj.setAssetScope();
|
|
|
|
expect(actionObj.scope).toEqual({assetClass: {"ALL": true}});
|
|
expect(actionObj.subActions).toEqual([]);
|
|
});
|
|
|
|
it(" getFirstLabel functions should get first label ", function() {
|
|
expect(actionObj.getFirstLabel('default')).toEqual('');
|
|
|
|
});
|
|
|
|
it(" removeLabel functions should delete label ", function() {
|
|
expect(actionObj.isLabelEmpty()).toBeTruthy();
|
|
expect(actionObj.labels).toEqual({ 'default':'' });
|
|
actionObj.removeLabel('default');
|
|
expect(actionObj.labels).toEqual({});
|
|
|
|
expect(actionObj.isLabelEmpty()).toBeFalsy();
|
|
});
|
|
|
|
it(" isUserInputChecked functions find actions and return true/false on found ", function() {
|
|
expect(actionObj.isUserInputChecked('')).toBeFalsy();
|
|
actionObj.subActions = [{'name':'assetUpdate','fields':['test']},{'name':'submit','fields':[]}]
|
|
expect(actionObj.isUserInputChecked('submit')).toBeTruthy();;
|
|
});
|
|
|
|
it(" isSupported functions find actions and return true/false on found ", function() {
|
|
expect(actionObj.isSupported('device')).toBeFalsy();
|
|
expect(actionObj.isSupported('web')).toBeTruthy();
|
|
|
|
});
|
|
|
|
it(" isAssetClassChecked functions find actions and return true/false on found ", function() {
|
|
actionObj.scope.assetClass = {"ALL": true,"TEST": 'testALL'};
|
|
|
|
expect(actionObj.isAssetClassChecked('ALL')).toBeTruthy();
|
|
expect(actionObj.isAssetClassChecked('NONE','SUB')).toBeFalsy();
|
|
expect(actionObj.isAssetClassChecked('TEST','SUB')).toBeFalsy();
|
|
expect(actionObj.isAssetClassChecked('TEST')).toBeTruthy();
|
|
expect(actionObj.isAssetClassChecked('ALLSUB')).toBeFalsy();
|
|
});
|
|
|
|
it(" functions should return boolean values depending on object evalution ", function() {
|
|
expect(actionObj.isAssetFieldChecked('save')).toBeFalsy();
|
|
expect(actionObj.isAssetFieldChecked('test')).toBeTruthy();
|
|
});
|
|
|
|
it(" setMapping should add obj to maaping property ", function() {
|
|
actionObj.setMapping([{}]);
|
|
expect(actionObj.mappings.length).toEqual(1);
|
|
});
|
|
|
|
it(" parseItem should remove unneccesary propeties from object for V3 ", function() {
|
|
actionObj.mode = {value:'both'};
|
|
actionObj.delete = false;
|
|
actionObj.mappings = [{mappedSource:{value:'test'},type: 'input'}];
|
|
actionObj.parseItem({id:2324});
|
|
expect(actionObj.mappings.length).toEqual(1);
|
|
});
|
|
|
|
it(" convertToOldVO used for transforming VO to old format ", function() {
|
|
actionObj.convertToOldVO();
|
|
expect(actionObj.mappings).not.toBeDefined();
|
|
});
|
|
|
|
|
|
it(" isV3ProviderAction should return boolean values depending on object evalution ", function() {
|
|
actionObj.resource = EntityVO.TYPE_ASSET;
|
|
expect(actionObj.isV3ProviderAction()).toBeFalsy();
|
|
actionObj.resource = EntityVO.TYPE_CHANGE;
|
|
expect(actionObj.isV3ProviderAction()).toBeTruthy();
|
|
});
|
|
}); |