/** * Created by mkumar1 on 09-05-2017. */ describe('Testing GlobalSearchItem VO', function () { var globalSearchItemVo; it('should create object and test properties', function () { globalSearchItemVo = new GlobalSearchItemVO(); expect(globalSearchItemVo.category).toEqual(''); expect(globalSearchItemVo.desc).toEqual(''); expect(globalSearchItemVo.displayId).toEqual(''); expect(globalSearchItemVo.id).toEqual(''); expect(globalSearchItemVo.title).toEqual(''); expect(globalSearchItemVo.type).toEqual(''); expect(globalSearchItemVo.templateName).toEqual(''); expect(globalSearchItemVo.subType).toEqual(''); expect(globalSearchItemVo.visited).toEqual(false); expect(globalSearchItemVo.relevancy).toEqual(0); expect(Object.keys(globalSearchItemVo.additionalInformation).length).toEqual(0); // testing blank object }); it('should test the inheritance with base', function() { expect(globalSearchItemVo instanceof BaseVO).toBeTruthy(); }); it('should verify all the properties', function () { var returnVal = globalSearchItemVo.getProps(); expect(returnVal).toEqual([ 'id', 'createDate', 'additionalInformation', 'category', 'desc', 'displayId', 'id', 'relevancy', 'title', 'type', 'templateName', 'visited', 'subType' ]); }); it('should return rating value', function () { var returnRating = globalSearchItemVo.getRating(); expect([globalSearchItemVo.additionalInformation.rating, 0]).toContain(returnRating); }); it('should return view count', function () { globalSearchItemVo.additionalInformation.viewCount = undefined; var numberOfView = globalSearchItemVo.getNumberOfViews(); expect(numberOfView).toEqual(-1); globalSearchItemVo.additionalInformation.viewCount = null; numberOfView = globalSearchItemVo.getNumberOfViews(); expect(numberOfView).toEqual(-1); globalSearchItemVo.additionalInformation.viewCount = 10; numberOfView = globalSearchItemVo.getNumberOfViews(); expect(numberOfView).toEqual(10); }); it('should return linked items', function () { globalSearchItemVo.additionalInformation.linkedItems = undefined; var numberOfLinkedItems = globalSearchItemVo.getNumberOfLinkedItems(); expect(numberOfLinkedItems).toEqual(-1); globalSearchItemVo.additionalInformation.linkedItems = null; numberOfLinkedItems = globalSearchItemVo.getNumberOfLinkedItems(); expect(numberOfLinkedItems).toEqual(-1); globalSearchItemVo.additionalInformation.linkedItems = 100; numberOfLinkedItems = globalSearchItemVo.getNumberOfLinkedItems(); expect(numberOfLinkedItems).toEqual(100); }); it('should verify modified date', function() { var dateVar = new Date(); globalSearchItemVo.additionalInformation.modifiedDate = dateVar; var lastModDate = globalSearchItemVo.getLastModifyDate(); expect(lastModDate).toEqual(dateVar); }); it('should reutrn status value', function() { globalSearchItemVo.additionalInformation.status = {value: "test"}; var statusVal = globalSearchItemVo.getStatus(); expect(statusVal).toEqual("test"); }); it('should verify full name property', function() { globalSearchItemVo.additionalInformation.assignee = {fullName: "Allen"}; var assigneeVal = globalSearchItemVo.getAssigneeFullName(); expect(assigneeVal).toEqual("Allen"); }); it('shoule check if it is decision tree or not', function() { globalSearchItemVo.templateName = "Normal Tree"; var isDecisionTreeFlag = globalSearchItemVo.isDecisionTree(); expect(isDecisionTreeFlag).toBeFalsy(); globalSearchItemVo.templateName = "Decision Tree"; isDecisionTreeFlag = globalSearchItemVo.isDecisionTree(); expect(isDecisionTreeFlag).toBeTruthy(); }); it('should test the post build features', function() { globalSearchItemVo.additionalInformation.isAutomatic = false; globalSearchItemVo.postBuild(); expect(globalSearchItemVo.subType).toEqual(""); globalSearchItemVo.additionalInformation.isAutomatic = true; globalSearchItemVo.postBuild(); expect(globalSearchItemVo.subType).toEqual("-auto"); }); });