Form and Date widget tests

This commit is contained in:
Denys Vuika
2016-10-12 21:31:08 +01:00
parent 3b3098ba59
commit 41671b97a3
4 changed files with 75 additions and 5 deletions

View File

@@ -634,4 +634,74 @@ describe('ActivitiForm', () => {
expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form);
});
it('should load form for ecm node', () => {
spyOn(formComponent, 'loadFormForEcmNode').and.stub();
formComponent.nodeId = '<id>';
formComponent.ngOnInit();
expect(formComponent.loadFormForEcmNode).toHaveBeenCalled();
});
it('should disable outcome buttons for readonly form', () => {
let formModel = new FormModel();
formModel.readOnly = true;
formComponent.form = formModel;
let outcome = new FormOutcomeModel(new FormModel(), {
id: ActivitiForm.CUSTOM_OUTCOME_ID,
name: 'Custom'
});
expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeFalsy();
});
it('should require outcome to eval button state', () => {
formComponent.form = new FormModel();
expect(formComponent.isOutcomeButtonEnabled(null)).toBeFalsy();
});
it('should always enable save outcome for writeable form', () => {
let formModel = new FormModel();
let field = new FormFieldModel(formModel, {
type: 'text',
value: null,
required: true
});
formComponent.form = formModel;
formModel.onFormFieldChanged(field);
expect(formModel.isValid).toBeFalsy();
let outcome = new FormOutcomeModel(new FormModel(), {
id: ActivitiForm.SAVE_OUTCOME_ID,
name: FormOutcomeModel.SAVE_ACTION
});
formComponent.readOnly = true;
expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeTruthy();
});
it('should disable oucome buttons for invalid form', () => {
let formModel = new FormModel();
let field = new FormFieldModel(formModel, {
type: 'text',
value: null,
required: true
});
formComponent.form = formModel;
formModel.onFormFieldChanged(field);
expect(formModel.isValid).toBeFalsy();
let outcome = new FormOutcomeModel(new FormModel(), {
id: ActivitiForm.CUSTOM_OUTCOME_ID,
name: 'Custom'
});
expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeFalsy();
});
});