100 lines
3.5 KiB
JavaScript
100 lines
3.5 KiB
JavaScript
describe('ProviderConfigurationController', function () {
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($rootScope, $controller, events, $state, adminConsoleConfigurationModel) {
|
|
this.scope = $rootScope.$new();
|
|
this.controller = $controller;
|
|
this.events = events;
|
|
this.$state = $state;
|
|
this.scope.displayData = [];
|
|
this.adminConsoleConfigurationModel = adminConsoleConfigurationModel;
|
|
|
|
this.controllerInstance = this.controller('ProviderConfigurationController', {
|
|
$scope: this.scope
|
|
});
|
|
}));
|
|
|
|
beforeEach(inject(function ($injector) {
|
|
var $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/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
|
|
}));
|
|
|
|
it('should defined', function () {
|
|
expect(this.controllerInstance).toBeDefined();
|
|
});
|
|
|
|
beforeEach(inject(function ($q, $rootScope) {
|
|
var deferred = $q.defer();
|
|
|
|
spyOn(this.adminConsoleConfigurationModel, "reloadProviders").and.callFake(function () {
|
|
deferred.resolve();
|
|
return deferred.promise;
|
|
});
|
|
|
|
}));
|
|
|
|
it('should call reload provider function', function () {
|
|
this.scope.reloadProviders();
|
|
this.scope.$apply();
|
|
expect(this.adminConsoleConfigurationModel.reloadProviders).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
it('should test valid label function', function () {
|
|
var setting = {
|
|
"id": "6337fce6-64c9-4f8e-a86f-37dbb4a95bf9",
|
|
"key": "mid_tier.base.url",
|
|
"value": "http://clm-pun-003257.bmc.com:8080/arsys",
|
|
"createDate": null,
|
|
"modifiedDate": null
|
|
};
|
|
|
|
this.scope.settingsLabelData = {
|
|
'host.name': 'Hostname',
|
|
'host.port': 'Port',
|
|
'system.user.password': 'Application password',
|
|
'mid_tier.base.url': 'Midtier URL',
|
|
'open.aif.new.window': 'Open AIF in new window',
|
|
'bppm.url': 'URL',
|
|
'check.password.expiration': 'Check password expiration',
|
|
'exchange.url': 'URL',
|
|
'exchange.login': 'Username',
|
|
'exchange.pass': 'Password',
|
|
'rkm.templates': 'RKM templates',
|
|
'statistics.enabled': 'Collect performance statistics',
|
|
'popular.catalog.item.threshold': 'Usage threshold for popular items',
|
|
'connect.arsystem.hostName': 'AR hostname',
|
|
'connect.arsystem.port': 'AR port',
|
|
'connect.arsystem.password': 'AR password'
|
|
};
|
|
|
|
var validLabel = this.scope.getValidLabel(setting);
|
|
this.scope.$apply();
|
|
expect(validLabel).toBe('Midtier URL');
|
|
});
|
|
|
|
it('should test valid label function', function () {
|
|
var setting = {
|
|
id: null,
|
|
key: "connect.arsystem.password",
|
|
value: null,
|
|
createDate: null,
|
|
modifiedDate: null
|
|
};
|
|
|
|
var validType = this.scope.getValidInputType(setting);
|
|
this.scope.$apply();
|
|
expect(validType).toBe('password');
|
|
|
|
});
|
|
});
|