describe('Directives: fulfillment map directive', function () { var scope, compile, $httpBackend, relationModel, configurationModel, systemAlertService, directiveElement, dfd; beforeEach(function () { module('myitsmApp', 'templates'); inject(function ($injector, $compile, $rootScope, _relationModel_, _configurationModel_, _systemAlertService_, $q) { $httpBackend = $injector.get('$httpBackend'); dfd = $q.defer(); var getLocale = function () { return readJSON('scripts/app/i18n/resources-locale_en.json'); }; $httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale()); $httpBackend.whenGET('views/search/search-filter.html').respond(200); $httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200); $httpBackend.whenGET('/smartit/rest/serverstates').respond(200); $httpBackend.whenGET('views/dashboard/index.html').respond(200); $httpBackend.whenGET('/smartit/rest/v2/metadata?type=change').respond(200); scope = $rootScope.$new(); compile = $compile; relationModel = _relationModel_; configurationModel = _configurationModel_; systemAlertService = _systemAlertService_; spyOn(relationModel, "refreshRelations").and.callFake(function () { dfd.resolve([{ "type": "changerequest", "displayId": "CRQ000000000115", "parentId": "336", "tag": "linkeditem", "realObject": { "status": { "value": "Draft" }, "processStepStatus": "ACTIVE", "appStatus": "Draft", "processStepType": "change", "sequence": 0, "title": "Elena Test Change request", "id": "AGGAA5V0GFBQEAPGBFJ9PFE9F5UM0K", "modifiedDate": 1521785577000 }, "id": "AGGAA5V0GFBQEAPGBFJ9PFE9F5UM0K" }]); return dfd.promise; }); spyOn(configurationModel, 'isServerApplicationEnabled').and.returnValue(true); }); directiveElement = createDirective(); }); function createDirective() { scope.context = { id: '1', type: 'sberequest', ticketType: 'sberequest' }; var compiledElem = compile(angular.element(''))(scope); scope.$digest(); return compiledElem; } it('should create fulfillment directive with service broker request', function () { var isolatedScope, divElem = directiveElement[0]; expect(divElem).toBeDefined(); isolatedScope = directiveElement.isolateScope(); expect(isolatedScope.context.type).toBe('sberequest'); scope.$digest(); expect(isolatedScope.activeRelatedTickets.length).toBe(1); }); });