SmartIT_Extensions/BMC/smart-it-full/test/app/custom-widgets/person-location-map-directi...

66 lines
2.4 KiB
JavaScript

describe('Test person location map directive', function () {
var compile, scope, $httpBackend, originalTimeout;
beforeEach(module('myitsmApp','templates'));
beforeEach(function(){
inject(function($compile, $rootScope, $injector, _objectValueMapperService_, _events_){
$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/serverstates').respond(200);
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
compile = $compile;
scope = $rootScope.$new();
objectValueMapperService = _objectValueMapperService_;
events = _events_;
});
});
beforeEach(function() {
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});
afterEach(function() {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});
function getCompiledElement(){
var element = angular.element('<person-location-map data="field"></person-location-map>');
var compiledElement = compile(element)(scope);
scope.$digest();
return compiledElement;
}
it('should compile', function(){
var field = {
googleMapAvailable: false,
dataType: 'widget'
};
scope.field = new FieldVO().build(field);
var directiveElem = getCompiledElement();
var divElem = directiveElem[0];
expect(divElem).toBeDefined();
});
it('should invoke watch for setValueFlag', function(){
var field = {
"id": "AGGAA5V0HG8SIAOTIDJZAB1ZVENZN5",
"name": "personLocation",
"type": "locationField",
"dataType": "widget"
};
scope.field = new FieldVO().build(field);
scope.field.setValueFlag = "Some text";
scope.$digest();
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
return { dataType: 'widget', value: {} };
});
var directiveElem = getCompiledElement();
expect(scope.field.setValueFlag).toEqual('#$#');
});
});