mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#726 fix unit tests
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
import { it, describe, expect } from '@angular/core/testing';
|
||||
import { ContainerColumnModel } from './container-column.model';
|
||||
import { FormModel } from './form.model';
|
||||
import { FormFieldModel } from './form-field.model';
|
||||
|
||||
describe('ContainerColumnModel', () => {
|
||||
@@ -35,7 +36,7 @@ describe('ContainerColumnModel', () => {
|
||||
column.fields = [];
|
||||
expect(column.hasFields()).toBeFalsy();
|
||||
|
||||
column.fields = [new FormFieldModel(null, null)];
|
||||
column.fields = [new FormFieldModel(new FormModel(), null)];
|
||||
expect(column.hasFields()).toBeTruthy();
|
||||
});
|
||||
|
||||
|
@@ -113,15 +113,6 @@ describe('FormFieldModel', () => {
|
||||
expect(field.readOnly).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should parse and convert empty dropdown value', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
value: ''
|
||||
});
|
||||
|
||||
expect(field.value).toBe('empty');
|
||||
});
|
||||
|
||||
it('should parse and leave dropdown value as is', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.DROPDOWN,
|
||||
@@ -145,19 +136,6 @@ describe('FormFieldModel', () => {
|
||||
expect(field.value).toBe('opt2');
|
||||
});
|
||||
|
||||
it('should parse and fall back to first radio button value', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.RADIO_BUTTONS,
|
||||
options: [
|
||||
{ id: 'opt1', value: 'Option 1' },
|
||||
{ id: 'opt2', value: 'Option 2' }
|
||||
],
|
||||
value: 'opt3'
|
||||
});
|
||||
|
||||
expect(field.value).toBe('opt1');
|
||||
});
|
||||
|
||||
it('should parse and leave radio button value as is', () => {
|
||||
let field = new FormFieldModel(new FormModel(), {
|
||||
type: FormFieldTypes.RADIO_BUTTONS,
|
||||
|
@@ -195,6 +195,10 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
}
|
||||
|
||||
updateForm() {
|
||||
if (!this.form) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.type) {
|
||||
case FormFieldTypes.DROPDOWN:
|
||||
/*
|
||||
|
@@ -37,7 +37,16 @@ describe('FunctionalGroupWidget', () => {
|
||||
it('should setup text from underlying field on init', () => {
|
||||
let group = new GroupModel({ name: 'group-1'});
|
||||
widget.field.value = group;
|
||||
|
||||
spyOn(formService, 'getWorkflowGroups').and.returnValue(
|
||||
Observable.create(observer => {
|
||||
observer.next([]);
|
||||
observer.complete();
|
||||
})
|
||||
);
|
||||
|
||||
widget.ngOnInit();
|
||||
expect(formService.getWorkflowGroups).toHaveBeenCalled();
|
||||
expect(widget.value).toBe(group.name);
|
||||
});
|
||||
|
||||
|
@@ -62,6 +62,12 @@ describe('PeopleWidget', () => {
|
||||
firstName: 'John',
|
||||
lastName: 'Doe'
|
||||
});
|
||||
|
||||
spyOn(formService, 'getWorkflowUsers').and.returnValue(Observable.create(observer => {
|
||||
observer.next([]);
|
||||
observer.complete();
|
||||
}));
|
||||
|
||||
widget.ngOnInit();
|
||||
expect(widget.value).toBe('John Doe');
|
||||
});
|
||||
|
@@ -50,7 +50,7 @@ describe('WidgetComponent', () => {
|
||||
let component = new WidgetComponent();
|
||||
|
||||
expect(component.hasField()).toBeFalsy();
|
||||
component.field = new FormFieldModel(null);
|
||||
component.field = new FormFieldModel(new FormModel());
|
||||
expect(component.hasField()).toBeTruthy();
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user