/** * Created by Sumit on 16/3/2018. */ describe('KnowledgeArticleController', function () { var $httpBackend, modalInstance; beforeEach(module('myitsmApp')); beforeEach(inject(function ($injector, $rootScope, $controller, $state, $q, i18nService, knowledgeArticleModel, $stateParams, followService, favoriteService, ticketActionService, events, metadataModel, categoriesService, $interval, $filter, systemAlertService, $modal, $timeout, configurationModel, knowledgeArticleService) { $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.$stateParams = $stateParams; this.followService = followService; this.favoriteService = favoriteService; this.ticketActionService = ticketActionService; this.events = events; this.metadataModel = metadataModel; this.categoriesService = categoriesService; this.$interval = $interval; this.$filter = $filter; this.systemAlertService = systemAlertService; this.$modal = $modal; this.$timeout = $timeout; this.configurationModel = configurationModel; this.knowledgeArticleService = knowledgeArticleService; 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('KnowledgeArticleController', { $scope: this.scope, $stateParams: { id: 12233 } }); })); beforeEach(inject(function ($q, $rootScope) { var deferred = $q.defer(); })); it('should defined', function () { expect(this.controllerInstance).toBeDefined(); }); it('should run getArticle()', function () { this.articleId = "AGGAA5V0HGOHVAPFO8XZPERXGVXOY6"; this.ignoreCache = false; this.preventIncrement = null; this.scope.getLatestVersion = true; this.scope.getArticle(this.articleId, this.ignoreCache, this.preventIncrement); expect(this.scope.getArticle).toBeDefined(); }); });