524 lines
21 KiB
JavaScript
524 lines
21 KiB
JavaScript
/**
|
|
* Created by abhatkha on 5/8/17.
|
|
*/
|
|
//This is test suite for baseVO
|
|
|
|
describe("Test FieldVO", function() {
|
|
|
|
var fieldObj;
|
|
it(" should do object creation ", function() {
|
|
|
|
fieldObj = new FieldVO();
|
|
expect(fieldObj instanceof BaseVO).toEqual(true);
|
|
expect(fieldObj instanceof FieldVO).toEqual(true);
|
|
|
|
});
|
|
|
|
it(" should do object initilization ", function() {
|
|
|
|
var fieldProp= fieldObj.getProps();
|
|
|
|
expect(fieldProp).toEqual([ 'id', 'createDate', 'name', 'label', 'type', 'dataType', 'required', 'itsmRequired', 'requiredCondition',
|
|
'requiredConditionFlag', 'itsmEditable', 'editable', 'readOnly', 'readOnlyCondition', 'readOnlyConditionFlag', 'hide', 'hideCondition',
|
|
'hideConditionFlag', 'setValueCondition', 'setValueConditionFlag', 'displayOrder', 'columnIndex', 'hideLabel',
|
|
'min', 'max', 'maxLength', 'precision', 'availability', 'menu', 'dependency', 'valueField', 'isDynamic',
|
|
'fieldUnavailableOn', 'members', 'groupMember', 'rowCount', 'arFieldName', 'value', 'extension', 'itsmFieldId',
|
|
'ootb', 'widgetMember', 'parentId', 'accessible', 'options']);
|
|
|
|
expect(fieldObj.id).not.toBeDefined();
|
|
expect(fieldObj.createDate).not.toBeDefined();
|
|
|
|
expect(fieldObj.name).toEqual('');
|
|
expect(fieldObj.label).toEqual('');
|
|
expect(fieldObj.arFieldName).toEqual('');
|
|
|
|
expect(fieldObj.type).toEqual('');
|
|
expect(fieldObj.dataType).toEqual('');
|
|
expect(fieldObj.required).toBeFalsy();
|
|
expect(fieldObj.editable).toBeTruthy();
|
|
expect(fieldObj.hideLabel).toBeFalsy();
|
|
expect(fieldObj.groupMember).toBeFalsy();
|
|
expect(fieldObj.expanded).toBeFalsy();
|
|
expect(fieldObj.sealed).toBeFalsy();
|
|
expect(fieldObj.hasValue).toBeFalsy();
|
|
expect(fieldObj.accessible).toBeTruthy();
|
|
expect(fieldObj.isDynamic).toBeFalsy();
|
|
expect(fieldObj.displayOrder ).toEqual(0);
|
|
expect(fieldObj.order).toEqual(0);
|
|
expect(fieldObj.columnIndex).toEqual(0);
|
|
expect(fieldObj.min).toEqual(0);
|
|
expect(fieldObj.max ).toEqual(0);
|
|
expect(fieldObj.maxLength ).toEqual(0);
|
|
expect(fieldObj.precision ).toEqual(0);
|
|
expect(fieldObj.availability ).toEqual(0);
|
|
expect(fieldObj.rowCount ).toEqual(0);
|
|
expect(fieldObj.dependency ).toEqual([]);
|
|
expect(fieldObj.fieldUnavailableOn ).toEqual([]);
|
|
expect(fieldObj.members ).toEqual([]);
|
|
expect(fieldObj.options ).toEqual([]);
|
|
expect(fieldObj.extension ).toEqual([]);
|
|
expect(fieldObj.valueField ).toBeNull();
|
|
expect(fieldObj.value ).toBeNull();
|
|
});
|
|
|
|
it(" should return boolean for diiffrent methods ", function() {
|
|
|
|
expect(fieldObj.isSealed()).toBeFalsy();
|
|
expect(fieldObj.isStaticSelectionField()).toBeFalsy();
|
|
expect(fieldObj.isSelectionField()).toBeFalsy();
|
|
expect(fieldObj.isDynamicSelectionField ()).toBeFalsy();
|
|
expect(fieldObj.isTextField()).toBeFalsy();
|
|
expect(fieldObj.isTextareaField()).toBeFalsy();
|
|
|
|
expect(fieldObj.isRadioField()).toBeFalsy();
|
|
expect(fieldObj.isDropdownField()).toBeFalsy();
|
|
expect(fieldObj.isCheckboxField()).toBeFalsy();
|
|
|
|
expect(fieldObj.isMenuField()).toBeFalsy();
|
|
expect(fieldObj.isNumberField()).toBeFalsy();
|
|
expect(fieldObj.isDateField()).toBeFalsy();
|
|
expect(fieldObj.isTimeField()).toBeFalsy();
|
|
expect(fieldObj.isDateTimeField()).toBeFalsy();
|
|
|
|
expect(fieldObj.hasDateDataType()).toBeFalsy();
|
|
expect(fieldObj.hasDateTimeDataType()).toBeFalsy();
|
|
expect(fieldObj.linkedFieldExist()).toBeFalsy();
|
|
expect(fieldObj.isGroupMember()).toBeFalsy();
|
|
expect(fieldObj.isVisible()).toBeFalsy();
|
|
expect(fieldObj.isAvailable()).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(" should return value from parseNumberValue method ", function() {
|
|
|
|
expect(fieldObj.parseNumberValue('test')).toEqual('test');
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_DECIMAL;
|
|
expect(fieldObj.parseNumberValue('3.5')).toEqual(3.5);
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_REAL;
|
|
expect(fieldObj.parseNumberValue('3.5')).toEqual(3.5);
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_INTEGER;
|
|
expect(fieldObj.parseNumberValue('8')).toEqual(8);
|
|
});
|
|
|
|
|
|
|
|
it(" should return value from setValue method ", function() {
|
|
|
|
|
|
fieldObj.type = FieldVO.prototype.NUMBER_FIELD;
|
|
fieldObj.setValue(123);
|
|
expect(fieldObj.value).toEqual(123);
|
|
|
|
fieldObj.type = FieldVO.prototype.DATE_TIME_FIELD;
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_TIME;
|
|
fieldObj.setValue(123);
|
|
expect(fieldObj.value).toBeDefined();
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_DATE;
|
|
fieldObj.setValue(123);
|
|
expect(fieldObj.value).toBeDefined();
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_DATE_TIME;
|
|
fieldObj.setValue(123);
|
|
expect(fieldObj.value).toBeDefined();
|
|
});
|
|
|
|
it(" should return value from getValue method ", function() {
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.hasValue = false;
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.hasValue = true;
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.type = FieldVO.prototype.NUMBER_FIELD;
|
|
fieldObj.setValue(17000);
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.type = FieldVO.prototype.DATE_TIME_FIELD;
|
|
//fieldObj.dataType = FieldVO.prototype.DATA_TYPE_TIME;
|
|
fieldObj.setValue(17000);
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.type = FieldVO.prototype.TIME_FIELD;
|
|
|
|
fieldObj.setValue(17000);
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_DATE;
|
|
fieldObj.setValue(17000);
|
|
fieldObj.getValue();
|
|
|
|
fieldObj.type = FieldVO.prototype.NUMBER_FIELD;
|
|
fieldObj.setValue(17000);
|
|
fieldObj.getValue();
|
|
|
|
});
|
|
|
|
|
|
it(" should return boolean from isDateField method ", function() {
|
|
|
|
expect(fieldObj.isDateField()).toBeFalsy();
|
|
fieldObj.type = FieldVO.prototype.DATE_FIELD;
|
|
expect(fieldObj.isDateField()).toBeTruthy();
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_DATE;
|
|
fieldObj.getValue();
|
|
fieldObj.dataType = FieldVO.prototype.DATA_TYPE_TIME;
|
|
fieldObj.getValue();
|
|
fieldObj.type = FieldVO.prototype.DATE_TIME_FIELD;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it(" should return date from prepareDateForTimeInput method ", function() {
|
|
|
|
expect(fieldObj.prepareDateForTimeInput(17000)).toBeDefined();
|
|
|
|
});
|
|
|
|
it(" should return value from getLinkedValue method ", function() {
|
|
expect(fieldObj.getLinkedValue()).not.toBeDefined();
|
|
});
|
|
|
|
it(" should return value from setLinkedFieldValue method ", function() {
|
|
|
|
fieldObj.setLinkedFieldValue('test');
|
|
fieldObj.valueField = 'test';
|
|
fieldObj.setLinkedFieldValue('test');
|
|
expect(fieldObj.valueLinkedField).toEqual('test');
|
|
});
|
|
|
|
it(" should execute clearValue method ", function() {
|
|
|
|
fieldObj.clearValue();
|
|
expect(fieldObj.value).toBeNull();
|
|
expect(fieldObj.hasValue).toBeFalsy();
|
|
});
|
|
|
|
it(" should execute clearLinkedFieldValue method ", function() {
|
|
fieldObj.clearLinkedFieldValue();
|
|
expect(fieldObj.valueLinkedField).toBeNull();
|
|
});
|
|
|
|
it(" should return boolean from isValid method ", function() {
|
|
expect(fieldObj.isValid()).toBeTruthy();
|
|
fieldObj.required = true;
|
|
expect(fieldObj.isValid()).toBeFalsy();
|
|
});
|
|
|
|
it(" should return boolean from isVisible method ", function() {
|
|
expect(fieldObj.isVisible()).toBeTruthy();
|
|
|
|
fieldObj.required = false;
|
|
expect(fieldObj.isVisible()).toBeFalsy();
|
|
|
|
fieldObj.type = FieldVO.prototype.GROUP_FIELD;
|
|
fieldObj.members = [{isVisible: function(){ return true; }}];
|
|
expect(fieldObj.isVisible()).toBeTruthy();
|
|
|
|
fieldObj.members = [{isVisible: function(){ return false; }}];
|
|
fieldObj.value = 'test';
|
|
expect(fieldObj.isVisible()).toBeTruthy();
|
|
|
|
|
|
});
|
|
|
|
it(' should check field is widget', function () {
|
|
var textField = new FieldVO().build({name: 'test', dataType: FieldVO.prototype.DATA_TYPE_TEXT});
|
|
var widget = new FieldVO().build({name: 'test', dataType: FieldVO.prototype.DATA_TYPE_WIDGET});
|
|
|
|
expect(textField.isWidget()).toBeFalsy();
|
|
expect(widget.isWidget()).toBeTruthy();
|
|
});
|
|
|
|
it(" should set field availability", function () {
|
|
var field = new FieldVO().build({name: 'test'});
|
|
|
|
field.markFieldUnavailable();
|
|
expect(field.availability).toEqual(1);
|
|
field.markFieldAvailable();
|
|
expect(field.availability).toEqual(0);
|
|
});
|
|
|
|
it(' should check if field is of specific type', function () {
|
|
var personNameField = new FieldVO().build({name: 'assignee', type: FieldVO.prototype.PERSON_NAME}),
|
|
affectedAssetField = new FieldVO().build({name: 'affectedAsset', type: FieldVO.prototype.AFFECTED_ASSET}),
|
|
descriptionField = new FieldVO().build({name: 'desc', type: FieldVO.prototype.DESCRIPTION}),
|
|
personSiteField = new FieldVO().build({name: 'site', type: FieldVO.prototype.PERSON_SITE}),
|
|
priorityField = new FieldVO().build({name: 'priority', type: FieldVO.prototype.PRIORITY}),
|
|
statusField = new FieldVO().build({name: 'status', type: FieldVO.prototype.STATUS}),
|
|
ticketRiskField = new FieldVO().build({name: 'risk', type: FieldVO.prototype.TICKET_RISK}),
|
|
organizationField = new FieldVO().build({name: 'org', type: FieldVO.prototype.ORGANIZATION_FIELD}),
|
|
personLocationMapField = new FieldVO().build({name: 'org', type: FieldVO.prototype.PERSON_LOCATION_MAP}),
|
|
supportGroupField = new FieldVO().build({name: 'supportGroup', type: FieldVO.prototype.SUPPORT_GROUP_FIELD}),
|
|
ticketTemplateField = new FieldVO().build({name: 'template', type: FieldVO.prototype.TICKET_TEMPLATE});
|
|
|
|
expect(affectedAssetField.isPersonName()).toBeFalsy();
|
|
expect(personNameField.isPersonName()).toBeTruthy();
|
|
|
|
expect(descriptionField.isAffectedAsset()).toBeFalsy();
|
|
expect(affectedAssetField.isAffectedAsset()).toBeTruthy();
|
|
|
|
expect(personNameField.isDescription()).toBeFalsy();
|
|
expect(descriptionField.isDescription()).toBeTruthy();
|
|
|
|
expect(descriptionField.isPersonSite()).toBeFalsy();
|
|
expect(personSiteField.isPersonSite()).toBeTruthy();
|
|
|
|
expect(descriptionField.isPriority()).toBeFalsy();
|
|
expect(priorityField.isPriority()).toBeTruthy();
|
|
|
|
expect(affectedAssetField.isStatus()).toBeFalsy();
|
|
expect(statusField.isStatus()).toBeTruthy();
|
|
|
|
expect(organizationField.isTicketRisk()).toBeFalsy();
|
|
expect(ticketRiskField.isTicketRisk()).toBeTruthy();
|
|
|
|
expect(personLocationMapField.isOrganizationField()).toBeFalsy();
|
|
expect(organizationField.isOrganizationField()).toBeTruthy();
|
|
|
|
expect(supportGroupField.isPersonLocationMap()).toBeFalsy();
|
|
expect(personLocationMapField.isPersonLocationMap()).toBeTruthy();
|
|
|
|
expect(ticketTemplateField.isSupportGroupField()).toBeFalsy();
|
|
expect(supportGroupField.isSupportGroupField()).toBeTruthy();
|
|
|
|
expect(priorityField.isTicketTemplate()).toBeFalsy();
|
|
expect(ticketTemplateField.isTicketTemplate()).toBeTruthy();
|
|
});
|
|
|
|
it(' should toggle field selection flag', function () {
|
|
fieldObj.disableFieldSelection();
|
|
|
|
expect(fieldObj.selectionDisabled).toBeTruthy();
|
|
|
|
fieldObj.enableFieldForSelection();
|
|
|
|
expect(fieldObj.selectionDisabled).toBeFalsy();
|
|
});
|
|
|
|
it(' should check fields equality', function () {
|
|
var field1 = new FieldVO().build({name: 'test', dataType: FieldVO.prototype.DATA_TYPE_TEXT, type: FieldVO.prototype.PERSON_NAME});
|
|
var field2 = new FieldVO().build({name: 'test', dataType: FieldVO.prototype.DATA_TYPE_TEXT, type: FieldVO.prototype.PERSON_NAME, readonly: true});
|
|
var field3 = new FieldVO().build({name: 'test', dataType: FieldVO.prototype.DATA_TYPE_CHECKBOX, type: FieldVO.prototype.PERSON_NAME});
|
|
var field4 = new FieldVO().build({name: 'test2', dataType: FieldVO.prototype.DATA_TYPE_CHECKBOX, type: FieldVO.prototype.PERSON_NAME});
|
|
|
|
expect(field1.isEqual(field3)).toBeFalsy();
|
|
expect(field3.isEqual(field4)).toBeFalsy();
|
|
|
|
expect(field1.isEqual(field2)).toBeTruthy()
|
|
});
|
|
|
|
it(' should check if field is custom', function () {
|
|
var customField = new FieldVO().build({name: 'custom', ootb: false, dataType: FieldVO.prototype.DATA_TYPE_CHECKBOX}),
|
|
ootbField = new FieldVO().build({name: 'ootb', ootb: true, dataType: FieldVO.prototype.DATA_TYPE_DROPDOWN}),
|
|
widget = new FieldVO().build({name: 'widget', ootb: false, dataType: FieldVO.prototype.DATA_TYPE_WIDGET});
|
|
|
|
expect(ootbField.isCustomField()).toBeFalsy();
|
|
expect(widget.isCustomField()).toBeFalsy();
|
|
|
|
expect(customField.isCustomField()).toBeTruthy();
|
|
});
|
|
|
|
it(' should fill parent widget information on member field', function () {
|
|
var member = new FieldVO().build({name: 'member', dataType: FieldVO.prototype.DATA_TYPE_TEXT});
|
|
var widget = new FieldVO().build({name: 'widget', dataType: FieldVO.prototype.DATA_TYPE_WIDGET, id: '1'});
|
|
|
|
expect(member.isWidgetMember()).toBeFalsy();
|
|
|
|
member.fillParentInfo(widget);
|
|
|
|
expect(member.isWidgetMember()).toBeTruthy();
|
|
expect(member.parentId).toEqual(widget.id);
|
|
});
|
|
|
|
it(' should check if field is accessible', function () {
|
|
var notAccessibleField = new FieldVO().build({name: 'member', dataType: FieldVO.prototype.DATA_TYPE_TEXT, accessible: false});
|
|
var widget = new FieldVO().build({name: 'widget', dataType: FieldVO.prototype.DATA_TYPE_WIDGET, members: []});
|
|
|
|
expect(widget.isAccessible()).toBeTruthy();
|
|
expect(notAccessibleField.isAccessible()).toBeFalsy();
|
|
|
|
widget.members.push(notAccessibleField);
|
|
|
|
expect(widget.isAccessible()).toBeFalsy();
|
|
});
|
|
|
|
it(' should check if field is editable', function () {
|
|
var accessMapping = {
|
|
fieldMappings: {
|
|
assignee: 'view',
|
|
priority: 'write'
|
|
},
|
|
detailsEditAllowed: true
|
|
};
|
|
|
|
var assigneeField = new FieldVO().build({name: 'assignee', dataType: FieldVO.prototype.DATA_TYPE_TEXT}),
|
|
priorityField = new FieldVO().build({name: 'priority', dataType: FieldVO.prototype.DATA_TYPE_MENU}),
|
|
otherField = new FieldVO().build({name: 'other', dataType: FieldVO.prototype.DATA_TYPE_CHECKBOX}),
|
|
widget = new FieldVO().build({name: 'widget', dataType: FieldVO.prototype.DATA_TYPE_WIDGET});
|
|
|
|
widget.members.push(otherField);
|
|
|
|
expect(otherField.isEditable(accessMapping)).toEqual(true);
|
|
expect(widget.isEditable(accessMapping)).toEqual(true);
|
|
|
|
accessMapping.detailsEditAllowed = false;
|
|
|
|
expect(otherField.isEditable(accessMapping)).toEqual(false);
|
|
expect(widget.isEditable(accessMapping)).toEqual(false);
|
|
|
|
expect(assigneeField.isEditable(accessMapping)).toEqual(false);
|
|
expect(priorityField.isEditable(accessMapping)).toEqual(true);
|
|
|
|
widget.members.push(priorityField);
|
|
|
|
expect(widget.isEditable(accessMapping)).toEqual(false);
|
|
|
|
widget.members = [priorityField];
|
|
|
|
expect(widget.isEditable(accessMapping)).toEqual(true);
|
|
|
|
widget.members.push(assigneeField);
|
|
|
|
expect(widget.isEditable(accessMapping)).toEqual(false);
|
|
|
|
});
|
|
|
|
it(' should check if field is specific widget', function () {
|
|
var priority = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.priority, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
changeClass = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeClass, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
assignee = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.assignee, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
changeCoordinator = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeCoordinator, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
changeManager = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeManager, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
customer = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.customer, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
requestedFor = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.requestedFor, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
contact = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.contact, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
supportGroup = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.assigneeSupportGroups, dataType: FieldVO.prototype.DATA_TYPE_WIDGET, type: FieldVO.prototype.SUPPORT_GROUP_FIELD}),
|
|
changeRisk = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeRisk, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
changeRiskBadge = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeRiskBadge, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
changeLocation = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.changeLocation, dataType: FieldVO.prototype.DATA_TYPE_WIDGET}),
|
|
impactedAreas = new FieldVO().build({name: FieldVO.prototype.WIDET_NAMES.impactedAreas, dataType: FieldVO.prototype.DATA_TYPE_WIDGET});
|
|
|
|
expect(changeClass.isPriorityWidget()).toEqual(false);
|
|
expect(priority.isPriorityWidget()).toEqual(true);
|
|
|
|
expect(priority.isChangeClassWidget()).toEqual(false);
|
|
expect(changeClass.isChangeClassWidget()).toEqual(true);
|
|
|
|
expect(changeClass.isAssigneeWidget()).toEqual(false);
|
|
expect(assignee.isAssigneeWidget()).toEqual(true);
|
|
expect(changeCoordinator.isAssigneeWidget()).toEqual(true);
|
|
expect(changeManager.isAssigneeWidget()).toEqual(true);
|
|
|
|
expect(changeManager.isCustomerWidget()).toEqual(false);
|
|
expect(customer.isCustomerWidget()).toEqual(true);
|
|
expect(requestedFor.isCustomerWidget()).toEqual(true);
|
|
|
|
expect(customer.isRequestedForWidget()).toEqual(false);
|
|
expect(requestedFor.isRequestedForWidget()).toEqual(true);
|
|
|
|
expect(requestedFor.isContactWidget()).toEqual(false);
|
|
expect(contact.isContactWidget()).toEqual(true);
|
|
|
|
expect(changeRisk.isSupportGroupWidget()).toEqual(false);
|
|
expect(supportGroup.isSupportGroupWidget()).toEqual(true);
|
|
|
|
expect(supportGroup.isChangeRiskWidget()).toEqual(false);
|
|
expect(changeRisk.isChangeRiskWidget()).toEqual(true);
|
|
|
|
expect(changeRisk.isChangeRiskBadgeWidget()).toEqual(false);
|
|
expect(changeRiskBadge.isChangeRiskBadgeWidget()).toEqual(true);
|
|
|
|
expect(impactedAreas.isChangeLocation()).toEqual(false);
|
|
expect(changeLocation.isChangeLocation()).toEqual(true);
|
|
|
|
expect(changeRisk.isImpactedAreas()).toEqual(false);
|
|
expect(impactedAreas.isImpactedAreas()).toEqual(true);
|
|
});
|
|
|
|
it(' should check if field is a member of current group field', function () {
|
|
var groupField = new FieldVO().build({
|
|
type: 'groupField',
|
|
dataType: 'group',
|
|
editable: true,
|
|
name: 'Customization Group',
|
|
label: 'Customization Group'
|
|
}),
|
|
groupMember = new FieldVO().build({name: 'member1', dataType: FieldVO.prototype.DATA_TYPE_MENU}),
|
|
groupMember2 = new FieldVO().build({name: 'member2', dataType: FieldVO.prototype.DATA_TYPE_MENU}),
|
|
field1 = new FieldVO().build({name: 'field1', dataType: FieldVO.prototype.DATA_TYPE_MENU}),
|
|
field2 = new FieldVO().build({name: 'member1', dataType: FieldVO.prototype.DATA_TYPE_CHECKBOX});
|
|
|
|
groupField.members.push(groupMember, groupMember2);
|
|
|
|
expect(groupField.isFieldMemberOfThisGroup(field1)).toEqual(false);
|
|
expect(groupField.isFieldMemberOfThisGroup(field2)).toEqual(false);
|
|
expect(groupField.isFieldMemberOfThisGroup(groupMember)).toEqual(true);
|
|
});
|
|
|
|
it(' should check if field is system required and missing from the screen', function () {
|
|
var systemRequiredField = new FieldVO().build({
|
|
name: 'systemRequired',
|
|
itsmRequired: true
|
|
}),
|
|
unavailableSystemRequiredField = new FieldVO().build({
|
|
name: 'unavailableSystemRequired',
|
|
availability: 1, // > 0 - means it is unavailable on current form
|
|
itsmRequired: true
|
|
}),
|
|
specialHandlingSystemRequiredField = new FieldVO().build({
|
|
name: 'submitter',
|
|
arFieldName: 'Submitter',
|
|
itsmFieldId: 2,
|
|
itsmRequired: true
|
|
}),
|
|
regularField = new FieldVO().build({
|
|
name: 'regular',
|
|
itsmRequired: false
|
|
});
|
|
|
|
expect(regularField.isMissingSystemRequiredField()).toEqual(false);
|
|
expect(unavailableSystemRequiredField.isMissingSystemRequiredField()).toEqual(false);
|
|
expect(specialHandlingSystemRequiredField.isMissingSystemRequiredField()).toEqual(false);
|
|
expect(systemRequiredField.isMissingSystemRequiredField()).toEqual(true);
|
|
|
|
systemRequiredField.disableFieldSelection();
|
|
|
|
expect(systemRequiredField.isMissingSystemRequiredField()).toEqual(false);
|
|
});
|
|
|
|
it('should check if field has date type value format', function () {
|
|
var testField = new FieldVO().build({
|
|
name: 'text',
|
|
dataType: 'test'
|
|
}),
|
|
dateField = new FieldVO().build({
|
|
name: 'text',
|
|
dataType: FieldVO.prototype.DATA_TYPE_DATE
|
|
}),
|
|
timeField = new FieldVO().build({
|
|
name: 'text',
|
|
dataType: FieldVO.prototype.DATA_TYPE_TIME
|
|
}),
|
|
dateTimeField = new FieldVO().build({
|
|
name: 'text',
|
|
dataType: FieldVO.prototype.DATA_TYPE_DATE_TIME
|
|
});
|
|
|
|
|
|
expect(testField.hasDataTypeValueFormat()).toEqual(false);
|
|
expect(dateField.hasDataTypeValueFormat()).toEqual(true);
|
|
expect(timeField.hasDataTypeValueFormat()).toEqual(true);
|
|
expect(dateTimeField.hasDataTypeValueFormat()).toEqual(true);
|
|
|
|
});
|
|
}); |