/** * Created by prenge on 13-04-2018. */ describe('Title bar directive', function() { var scope, rootScope, compile, $httpBackend; beforeEach(module('myitsmApp', 'templates')); beforeEach(function() { inject(function ($compile, $rootScope, $injector, events) { compile = $compile; this.events = events; $httpBackend = $injector.get('$httpBackend'); rootScope = $rootScope; scope = $rootScope.$new(); var getLocale = function () { return readJSON('scripts/app/i18n/resources-locale_en.json'); }; $httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale()); $httpBackend.whenGET('/smartit/rest/v2/metadata?type=global').respond(200); $httpBackend.whenGET('/smartit/rest/v2/metadata?type=change').respond(200); $httpBackend.whenGET(/^\/smartit\/rest\/foundation\/items*/).respond(200); $httpBackend.whenGET('/smartit/rest/v3/action/search?resourceType=change').respond(200); $httpBackend.whenGET('/smartit/restapi/person/supportgroupperson').respond(200); $httpBackend.whenGET('/smartit/rest/v2/customization/screenlayout?screen=changeViewScreen').respond(200); $httpBackend.whenGET('/smartit/rest/serverstates').respond(200); $httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200); }) }); function getCompiledElement(basicData, moreDropDownOptions, screenLayout, metadata, isFullVersion) { scope.isFullVersion = isFullVersion; scope.moreDropDownOptions = moreDropDownOptions; scope.ticket = basicData; scope.screenLayout = screenLayout; scope.metadata = metadata; var element = angular.element(''), compiledElement = compile(element)(scope); scope.$digest(); return compiledElement; } it('should compile', function () { var basicData = { "displayId": "CRQ7", "type" : "change", "entryId" : "CRQ000000000109", "status" : "Draft", }, moreDropDownOptions = { "actions" : [{"label" : "initiateimpactanalysis", "method" : "runImpactAnalysis", "$$hashKey" : "object : 244"}], "registeredCallbacks" : {} }, screenLayout = { 'id' : "AGHAA5V0HGOWWAOU6P3DA5NJK7BAFL", "layout" : "row", "name" : "changeViewScreen", }, metadata = { "metadatatype": "change", }, isFullVersion = true, directiveElem = getCompiledElement(basicData, moreDropDownOptions, screenLayout, metadata, isFullVersion), divElem = directiveElem[0]; expect(divElem).toBeDefined(); var updatedTicket = { "displayId": "CRQ7", "type" : "change", "entryId" : "CRQ000000000109", "status" : "Pending", } rootScope.$broadcast("afterSavedChanges", updatedTicket); scope.$digest(); expect(scope.ticket).toEqual(updatedTicket); }); })