SmartIT_Extensions/BMC/smart-it-full/test/app/person/person-preview-directive.sp...

43 lines
1.5 KiB
JavaScript

/*** Created by npatil2 .*/
describe('person preview directive', function () {
var scope, compile, $httpBackend;
beforeEach(module('myitsmApp', 'templates', 'personModule'));
beforeEach(function () {
inject(function ($compile, $rootScope, $injector) {
$httpBackend = $injector.get('$httpBackend');
this.$rootScope = $rootScope;
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);
compile = $compile;
scope = $rootScope.$new();
});
});
function getCompiledElement() {
var element = angular.element('<div class="person-preview"> </div>'), compiledElement = compile(element)(scope);
scope.$digest();
return compiledElement;
}
it('should compile person preview directive', inject(function ($rootScope) {
var directiveElem = getCompiledElement(), divElem = directiveElem[0];
expect(divElem).toBeDefined();
}));
it('should defined directive element', function () {
var directiveElem = getCompiledElement(), divElem = directiveElem.scope();
divElem.personId = 1233;
divElem.$apply();
expect(divElem.personId).toEqual(1233);
});
});