82 lines
3.7 KiB
JavaScript
82 lines
3.7 KiB
JavaScript
/*** Created by npatil2 .*/
|
|
describe('service: fieldValidationModel', function () {
|
|
var $httpBackend, $rootScope, scope;
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function ($injector, $rootScope, configurationModel) {
|
|
this.configurationModel = configurationModel;
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
scope = $rootScope.$new();
|
|
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);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
$rootScope = $injector.get('$rootScope');
|
|
this.fieldValidationModel = $injector.get('fieldValidationModel');
|
|
}));
|
|
|
|
it('should be defined', function () {
|
|
expect(this.fieldValidationModel).toBeDefined();
|
|
});
|
|
|
|
it('should Field Required ', function () {
|
|
this.ticketType = 'change';
|
|
this.status = 'Scheduled';
|
|
this.timing = 'Emergency';
|
|
this.field = 'scheduledStartDate';
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
scope.$apply();
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'problem';
|
|
this.status = 'Assigned';
|
|
this.timing = null;
|
|
this.field = 'coordinator';
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'incident';
|
|
this.status = 'Pending';
|
|
this.field = 'statusReason';
|
|
this.timing = null;
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'task';
|
|
this.status = 'Closed';
|
|
this.field = 'statusReason';
|
|
this.timing = null;
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'release';
|
|
this.status = 'Pending';
|
|
this.field = 'statusReason';
|
|
this.timing = null;
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'default';
|
|
this.status = 'Pending';
|
|
this.field = 'statusReason';
|
|
this.timing = null;
|
|
this.myResult = this.fieldValidationModel.isFieldRequired(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(false);
|
|
});
|
|
|
|
it('should Field Disabled ', function () {
|
|
this.ticketType = 'change';
|
|
this.status = 'Draft';
|
|
this.timing = 'Emergency';
|
|
this.field = 'targetDate';
|
|
this.myResult = this.fieldValidationModel.isFieldDisabled(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(true);
|
|
this.ticketType = 'default';
|
|
this.myResult = this.fieldValidationModel.isFieldDisabled(this.ticketType, this.status, this.timing, this.field);
|
|
expect(this.myResult).toBe(false);
|
|
});
|
|
|
|
it('should Future Date Time ', function () {
|
|
var DateTime = new Date();
|
|
this.myResult = this.fieldValidationModel.isFutureDateTime(DateTime);
|
|
expect(this.myResult).toBe(false);
|
|
});
|
|
}); |