/** * Created by abhatkha on 5/8/17. */ //This is test suite for baseVO describe("Test FeedItemVO", function() { var feedItemObj; var eventObj = new EventVO(); it(" should create object ", function() { feedItemObj = new FeedItemVO(); expect(feedItemObj instanceof BaseVO).toEqual(true); expect(feedItemObj instanceof FeedItemVO).toEqual(true); }); it(" should initilize objects with all properties ", function() { var feedItemObjProp= feedItemObj.getProps(); expect(FeedItemVO.prototype.TYPE_SYSTEM).toEqual('system'); expect(FeedItemVO.prototype.TYPE_COMMENT).toEqual('comment'); expect(FeedItemVO.prototype.TYPE_OUTAGE).toEqual('outage'); expect(FeedItemVO.prototype.TYPE_BROADCAST).toEqual('broadcast'); expect(FeedItemVO.WORK_INFO_TYPES).toEqual({incident: 16000, task: 16000, workorder: 31000, change: 31000, release: 31000, activity: 31000}); expect(FeedItemVO.WORK_INFO_TYPES[EntityVO.TYPE_INCIDENT]).toEqual(16000); expect(FeedItemVO.WORK_INFO_TYPES[EntityVO.TYPE_TASK]).toEqual(16000); expect(FeedItemVO.WORK_INFO_TYPES[EntityVO.TYPE_WORKORDER]).toEqual(31000); expect(FeedItemVO.WORK_INFO_TYPES[EntityVO.TYPE_CHANGE]).toEqual(31000); expect(FeedItemVO.WORK_INFO_TYPES[EntityVO.TYPE_RELEASE]).toEqual(31000); expect(feedItemObjProp).toEqual(['id', 'createDate','type', 'priority', 'isSystemGenerated', 'author', 'relatedObject', 'event', 'note', 'attachments', 'attachmentCount']); expect(feedItemObj.id).not.toBeDefined(); expect(feedItemObj.createDate).not.toBeDefined(); expect(feedItemObj.priority).toEqual(0); expect(feedItemObj.isSystemGenerated).toEqual(''); expect(feedItemObj.author).toBeNull(); expect(feedItemObj.relatedObject).toBeNull(); expect(feedItemObj.event).toBeNull(); expect(feedItemObj.note).toBeNull(); expect(feedItemObj.attachments).toBeNull(); expect(feedItemObj.attachmentCount).toEqual(0); expect(feedItemObj.createDateLabel ).toEqual(''); expect(feedItemObj.message ).toEqual(''); expect(feedItemObj.expanded).toBeFalsy(); expect(feedItemObj.repliesExpanded ).toBeFalsy(); expect(feedItemObj.title).toEqual(''); expect(feedItemObj.tagLine).toEqual(''); }); it(" should return boolean for isSystemUpdate method ", function() { expect(feedItemObj.isSystemUpdate()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM; expect(feedItemObj.isSystemUpdate()).toBeTruthy(); }); it(" should return boolean for isOutage method ", function() { expect(feedItemObj.isOutage()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_OUTAGE; expect(feedItemObj.isOutage()).toBeTruthy(); }); it(" should return boolean for isBroadcast method ", function() { expect(feedItemObj.isBroadcast()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_BROADCAST; expect(feedItemObj.isBroadcast()).toBeTruthy(); }); it(" should return boolean for isKnowledge method ", function() { expect(feedItemObj.isKnowledge()).toBeFalsy(); feedItemObj.relatedObject = {type:''}; expect(feedItemObj.isKnowledge()).toBeFalsy(); feedItemObj.relatedObject.type = EntityVO.TYPE_KNOWLEDGE; expect(feedItemObj.isKnowledge()).toBeTruthy(); }); it(" should return boolean for isComment method ", function() { expect(feedItemObj.isComment()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_COMMENT; expect(feedItemObj.isComment()).toBeTruthy(); }); it(" should return boolean for isUnflaggingResponse method ", function() { feedItemObj.event = new EventVO(); // feedItemObj.event = {eventType:''}; expect(feedItemObj.isUnflaggingResponse()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.UNFLAG; expect(feedItemObj.isUnflaggingResponse()).toBeTruthy(); }); it(" should return boolean for isFlag method ", function() { feedItemObj.event.eventType = ''; expect(feedItemObj.isFlag()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.FLAG; expect(feedItemObj.isFlag()).toBeTruthy(); }); it(" should return boolean for isUnFlag method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isUnFlag()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.UNFLAG; expect(feedItemObj.isUnFlag()).toBeTruthy(); }); it(" should return boolean for isMyITComment method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isMyITComment()).toBeFalsy(); feedItemObj.note = {conversationRefId:1}; feedItemObj.type = FeedItemVO.prototype.TYPE_COMMENT; expect(feedItemObj.isMyITComment()).toBeTruthy(); }); it(" should return boolean for isEmail method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isEmail()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.EMAIL; expect(feedItemObj.isEmail()).toBeTruthy(); }); it(" should return boolean for isSlaChange method ", function() { expect(feedItemObj.isSlaChange()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM;; feedItemObj.event.eventType = EventVO.prototype.SLA_CHANGE; expect(feedItemObj.isSlaChange()).toBeTruthy(); }); it(" should return boolean for isApprovalReject method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isApprovalReject()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM; feedItemObj.event.eventType = 'approval-reject-event'; expect(feedItemObj.isApprovalReject()).toBeTruthy(); }); it(" should return boolean for isApprovalHold method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isApprovalHold()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM; feedItemObj.event.eventType = 'approval-hold-event'; expect(feedItemObj.isApprovalHold()).toBeTruthy(); }); it(" should return boolean for isApprovalAccept method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isApprovalAccept()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM; feedItemObj.event.eventType = 'approval-accept-event'; expect(feedItemObj.isApprovalAccept()).toBeTruthy(); }); it(" should return boolean for isRelationshipChange method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isRelationshipChange()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.UNRELATED_CHANGE; expect(feedItemObj.isRelationshipChange()).toBeTruthy(); feedItemObj.event.eventType = EventVO.prototype.RELATED_CHANGE; expect(feedItemObj.isRelationshipChange()).toBeTruthy(); }); it(" should return boolean for isLocationChange method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isLocationChange()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.LOCATION_CHANGE; expect(feedItemObj.isLocationChange()).toBeTruthy(); }); it(" should return boolean for isOwnerChange method ", function() { feedItemObj.event.eventType=''; expect(feedItemObj.isOwnerChange()).toBeFalsy(); feedItemObj.event.eventType = EventVO.prototype.OWNERSHIP_CHANGE; expect(feedItemObj.isOwnerChange()).toBeTruthy(); }); it(" should return boolean for isSharedWithVendor method ", function() { expect(feedItemObj.isSharedWithVendor()).toBeFalsy(); feedItemObj.note = {shareWithVendor: true}; expect(feedItemObj.isSharedWithVendor()).toBeTruthy(); }); it(" should return boolean for iconFunction method ", function() { feedItemObj.event.eventType=''; feedItemObj.relatedObject.type = undefined; expect(feedItemObj.iconFunction()).toEqual(''); feedItemObj.relatedObject.type = EntityVO.TYPE_ASSET; expect(feedItemObj.iconFunction()).toEqual('icon-asset'); feedItemObj.relatedObject.type = EntityVO.TYPE_INCIDENT; expect(feedItemObj.iconFunction()).toEqual('icon-incident'); feedItemObj.relatedObject.type = EntityVO.TYPE_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-change'); feedItemObj.event.classId = "Automation System"; expect(feedItemObj.iconFunction()).toEqual('icon-files_change_auto'); feedItemObj.event.classId = "Automatic"; expect(feedItemObj.iconFunction()).toEqual('icon-file_task_auto'); feedItemObj.event.classId = "Manual"; expect(feedItemObj.iconFunction()).toEqual('icon-file_task_o'); feedItemObj.relatedObject.type = EntityVO.TYPE_WORKORDER; expect(feedItemObj.iconFunction()).toEqual('icon-workorder'); feedItemObj.relatedObject.type = EntityVO.TYPE_TASK; expect(feedItemObj.iconFunction()).toEqual('icon-task'); feedItemObj.event.classId = "Automatic"; expect(feedItemObj.iconFunction()).toEqual('icon-file_task_auto'); feedItemObj.relatedObject.type = EntityVO.TYPE_KNOWLEDGE; expect(feedItemObj.iconFunction()).toEqual('icon-knowledge'); feedItemObj.event.classId = "RKM:DecisionTreeTemplate"; expect(feedItemObj.iconFunction()).toEqual('icon-decision-tree'); feedItemObj.relatedObject.type = EntityVO.TYPE_PROBLEM; expect(feedItemObj.iconFunction()).toEqual('icon-problem'); feedItemObj.relatedObject.type = EntityVO.TYPE_KNOWNERROR; expect(feedItemObj.iconFunction()).toEqual('icon-knownerror'); feedItemObj.relatedObject.type = EntityVO.TYPE_SERVICEREQUEST; expect(feedItemObj.iconFunction()).toEqual('icon-request'); feedItemObj.relatedObject.type = EntityVO.TYPE_RELEASE; expect(feedItemObj.iconFunction()).toEqual('icon-release'); feedItemObj.relatedObject.type = EntityVO.TYPE_ACTIVITY; expect(feedItemObj.iconFunction()).toEqual('icon-activity'); feedItemObj.type = FeedItemVO.prototype.TYPE_BROADCAST; expect(feedItemObj.iconFunction()).toEqual('icon-speaker'); feedItemObj.type = FeedItemVO.prototype.TYPE_SYSTEM; feedItemObj.event.eventType = EventVO.prototype.SLA_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-exclamation_triangle'); feedItemObj.event.eventType = 'approval-hold-event'; expect(feedItemObj.iconFunction()).toEqual('icon-sandglass'); feedItemObj.event.eventType = 'approval-reject-event'; expect(feedItemObj.iconFunction()).toEqual('icon-cross_square'); feedItemObj.event.eventType = 'approval-accept-event'; expect(feedItemObj.iconFunction()).toEqual('icon-check_shield'); feedItemObj.event.eventType = EventVO.prototype.RELATED_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-link'); feedItemObj.event.eventType = EventVO.prototype.LOCATION_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-mapmarker'); feedItemObj.relatedObject.type = EntityVO.TYPE_INCIDENT; feedItemObj.event.eventType = EventVO.prototype.VENDOR_CREATE; expect(feedItemObj.iconFunction()).toEqual('icon-incident-brokered'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_CREATE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-incident-brokered'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_NOTE; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_NOTE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_STATUS_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_STATUS_CHANGE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.relatedObject.type = EntityVO.TYPE_CHANGE; feedItemObj.event.eventType = EventVO.prototype.VENDOR_CREATE; expect(feedItemObj.iconFunction()).toEqual('icon-change-brokered'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_CREATE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-change-brokered'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_NOTE; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_NOTE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_STATUS_CHANGE; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); feedItemObj.event.eventType = EventVO.prototype.VENDOR_STATUS_CHANGE_V2; expect(feedItemObj.iconFunction()).toEqual('icon-cloud_user'); }); it(" should return boolean for hasAttachments method ", function() { expect(feedItemObj.hasAttachments()).toBeFalsy(); feedItemObj.note ={attachmentCount:1}; feedItemObj.type = FeedItemVO.prototype.TYPE_BROADCAST; expect(feedItemObj.hasAttachments()).toBeTruthy(); }); it(" should return boolean for hasComments method ", function() { expect(feedItemObj.hasComments()).toBeFalsy(); feedItemObj.type = FeedItemVO.prototype.TYPE_COMMENT; feedItemObj.note ={commentCount :1}; expect(feedItemObj.hasComments()).toBeTruthy(); }); it(" should return boolean for hasReplies method ", function() { expect(feedItemObj.hasReplies()).toBeFalsy(); feedItemObj.replies = {}; feedItemObj.note ={repliesCount :1}; expect(feedItemObj.hasReplies()).toBeTruthy(); }); it(" should return boolean for hasUnflaggingResponse method ", function() { expect(feedItemObj.hasUnflaggingResponse()).toBeFalsy(); feedItemObj.replies = [{isUnflaggingResponse:function(){return true;}}]; expect(feedItemObj.hasUnflaggingResponse()).toBeTruthy(); feedItemObj.replies = [{isUnflaggingResponse:function(){return false;}}]; expect(feedItemObj.hasUnflaggingResponse()).toBeFalsy(); }); it(" should run toggle method ", function() { feedItemObj.toggle(); expect(feedItemObj.expanded).toBeTruthy(); feedItemObj.toggle(); expect(feedItemObj.expanded).toBeFalsy(); }); it(" should run toggleRepliesView method ", function() { feedItemObj.toggleRepliesView(); expect(feedItemObj.repliesExpanded).toBeTruthy(); feedItemObj.toggleRepliesView(); expect(feedItemObj.repliesExpanded).toBeFalsy(); }); it(" should run postBuild method ", function() { feedItemObj.postBuild(); feedItemObj.relatedObject.type = EntityVO.SOCIAL_PROFILE_USER; feedItemObj.type = FeedItemVO.prototype.TYPE_OUTAGE; feedItemObj.postBuild(); expect(feedItemObj.relatedObject.type).toEqual(EntityVO.TYPE_PERSON); expect(feedItemObj.title).toEqual(feedItemObj.event.title); feedItemObj.type = FeedItemVO.prototype.TYPE_BROADCAST; feedItemObj.postBuild(); feedItemObj.relatedObject = new RelatedObjectVO(); feedItemObj.relatedObject.type = EntityVO.TYPE_ASSET; feedItemObj.postBuild(); expect(feedItemObj.relatedObject.showHeader).toBeFalsy(); feedItemObj.note = {conversationRefId:1}; feedItemObj.type = FeedItemVO.prototype.TYPE_COMMENT; feedItemObj.message = '@testtes|tstest|asset'; feedItemObj.postBuild(); expect(feedItemObj.relatedObject).toBeNull(); }); });