52 lines
2.2 KiB
JavaScript
52 lines
2.2 KiB
JavaScript
/*** Created by npatil2.*/
|
|
describe('service: functionEvaluatorService', function () {
|
|
var $httpBackend;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($injector, objectValueMapperService) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
$httpBackend.whenGET('scripts/app/i18n/resources-locale_en-US.json').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);
|
|
this.functionEvaluatorService = $injector.get('functionEvaluatorService');
|
|
sinon.stub(objectValueMapperService, 'getFieldPropertyValue')
|
|
.withArgs('statusReason', 'isRequired').returns(true)
|
|
.withArgs('statusReason', 'isReadOnly').returns(true)
|
|
.withArgs('statusReason', 'isHidden').returns(true);
|
|
sinon.stub(objectValueMapperService, 'getProviderActionFieldName').returns('statusReason');
|
|
}));
|
|
|
|
it('should defined', function () {
|
|
expect(this.functionEvaluatorService).toBeDefined();
|
|
});
|
|
|
|
it('should run execute', function () {
|
|
this.functionName = 'NOOP';
|
|
this.parameters = ['data', 'test'];
|
|
|
|
this.myResult = this.functionEvaluatorService.execute(this.functionName, this.parameters);
|
|
|
|
expect(this.myResult).toEqual(angular.noop);
|
|
|
|
this.functionName = 'INGROUP';
|
|
|
|
this.myResult = this.functionEvaluatorService.execute(this.functionName, this.parameters);
|
|
expect(this.myResult).toEqual(false);
|
|
|
|
this.functionName = 'ISREQUIRED';
|
|
this.parameters = ['statusReason'];
|
|
|
|
expect(this.functionEvaluatorService.execute(this.functionName, this.parameters)).toBeTruthy();
|
|
|
|
this.functionName = 'ISREADONLY';
|
|
expect(this.functionEvaluatorService.execute(this.functionName, this.parameters)).toBeTruthy();
|
|
|
|
this.functionName = 'ISHIDDEN';
|
|
expect(this.functionEvaluatorService.execute(this.functionName, this.parameters)).toBeTruthy();
|
|
|
|
this.functionName = 'ONCHANGE';
|
|
expect(this.functionEvaluatorService.execute(this.functionName, this.parameters)).toBeTruthy();
|
|
|
|
});
|
|
}); |