describe('KnowledgeArticleProfileController', function () { var $httpBackend; beforeEach(module('myitsmApp')); beforeEach(inject(function ($injector, $rootScope, $controller, $state, $q, i18nService, knowledgeArticleModel, events) { $httpBackend = $injector.get('$httpBackend'); this.$rootScope = $rootScope; this.scope = $rootScope.$new(); this.controller = $controller; this.$state = $state; this.i18nService = i18nService; this.$q = $q; this.knowledgeArticleModel = knowledgeArticleModel; this.events = events; 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/serverstates').respond(200); $httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200); this.controllerInstance = this.controller('KnowledgeArticleProfileController', { $scope: this.scope }); })); it(' should be defined', function () { expect(this.controllerInstance).toBeDefined(); }); it(' should trigger event KNOWLEDGE_ARTICLE_LOADED', function () { this.article = { id: 'abc', accessMappings: { detailsEditAllowed: true } }; this.scope.hideEditButton = true; this.$rootScope.$broadcast(this.events.KNOWLEDGE_ARTICLE_LOADED, { article: this.article, isEditMode: false }); expect(this.scope.article.id).toEqual('abc'); expect(this.scope.hideEditButton).toBeFalsy(); }); });