/*** Created by npatil2 .*/ describe('service: ciRelationsModel', function () { var $httpBackend, $rootScope, scope; beforeEach(module('myitsmApp')); beforeEach(inject(function ($injector, consoleService, configurationModel, metadataModel, userModel, $rootScope, $q, $window) { scope = $rootScope.$new(); $httpBackend = $injector.get('$httpBackend'); $httpBackend.whenGET('scripts/app/i18n/resources-locale_en-US.json').respond(200); $httpBackend.whenGET('/smartit/restapi/person/supportgroupperson').respond(200); $httpBackend.whenGET('/smartit/rest/v2/following/stream').respond(200); $httpBackend.whenGET('/smartit/rest/serverstates').respond(200); $httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200); $httpBackend.whenGET('views/dashboard/index.html').respond(200); $rootScope = $injector.get('$rootScope'); this.ciRelationsModel = $injector.get('ciRelationsModel'); this.consoleService = consoleService; this.configurationModel = configurationModel; this.metadataModel = metadataModel; this.userModel = userModel; this.$q = $q; this.$window = $window; })); beforeEach(inject(function ($q) { var deferred = $q.defer(), config = ['test', 'test1', 'test2']; spyOn(this.userModel, 'getUserPreferences').and.callFake(function () { deferred.resolve(config); return deferred.promise; }); spyOn(this.userModel, 'updateUserPreferences').and.callFake(function () { deferred.resolve(config); return deferred.promise; }); })); it('should populate Configuration ', function () { this.ciRelationsModel.columnsConfig = { test: 'test1', test2: 'test 3' }; this.myResult = this.ciRelationsModel.populateConfiguration(); scope.$apply(); expect(this.myResult.$$state.value).toEqual(1); this.ciRelationsModel.columnsConfig = null; this.myResult = this.ciRelationsModel.populateConfiguration(); scope.$apply(); expect(this.myResult.$$state.value.classId).toBeDefined(); expect(this.myResult.$$state.value.name).toBeDefined(); expect(this.myResult.$$state.value.type).toBeDefined(); }); it('should update Column Config ', function () { this.ciRelationsModel.columnsConfig = { test: 'test1', test2: 'test 3' }; this.myResult = this.ciRelationsModel.updateColumnConfig(this.ciRelationsModel.columnsConfig); scope.$apply(); }); });