/*** Created by npatil2 .*/ describe('Directives: assetUpdate ', function () { var scope, compile, $httpBackend; beforeEach(module('myitsmApp', 'templates', 'assetModule')); beforeEach(function () { inject(function ($compile, $rootScope, $injector) { $httpBackend = $injector.get('$httpBackend'); 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/restapi/person/supportgroupperson').respond(200); $httpBackend.whenGET('/smartit/rest/v2/metadata?type=asset').respond(200); $httpBackend.whenGET('/smartit/rest/serverstates').respond(200); $httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200); compile = $compile; scope = $rootScope.$new(); }); }); function getCompiledElement() { var element = angular.element(''), compiledElement = compile(element)(scope); scope.$digest(); return compiledElement; } it('should compile asset update directive', function () { var directiveElem = getCompiledElement(), divElem = directiveElem[0]; expect(divElem).toBeDefined(); }); it('should defined directive element', function () { var directiveElem = getCompiledElement(), divElem = directiveElem.scope(); divElem.assetUpdateFields = 'test data'; divElem.assetUpdateForm = 'test asset update data'; divElem.$apply(); expect(divElem.assetUpdateFields).toEqual('test data'); expect(divElem.assetUpdateForm).toEqual('test asset update data'); }); });