[AAE-1943] Dropdown widget unit test (#5513)

* [AAE-2034] Radio Button displaued in read-only mode

* [AAE-2034] Added tests and disable for all radio group and not every button

* [AAE-1943] C309672 and C309675 into unit tests

* [AAE-1943] C309680 automated

* [AAE-1943] C309682 automated
This commit is contained in:
Baptiste Mahé
2020-02-28 14:03:13 +00:00
committed by GitHub
parent a9b49a1eb7
commit 7a79d5bebf
4 changed files with 335 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import { WidgetVisibilityService } from '../../../services/widget-visibility.ser
import { FormFieldOption } from './../core/form-field-option';
import { FormFieldModel } from './../core/form-field.model';
import { FormModel } from './../core/form.model';
import { FormFieldTypes } from '../core/form-field-types';
import { DropdownWidgetComponent } from './dropdown.widget';
import { setupTestBed } from '../../../../testing/setup-test-bed';
import { CoreModule } from '../../../../core.module';
@@ -123,6 +124,39 @@ describe('DropdownWidgetComponent', () => {
expect(widget.field.options[1]).toBe(restFieldValue);
});
describe('when is required', () => {
beforeEach(async(() => {
widget.field = new FormFieldModel( new FormModel({ taskId: '<id>' }), {
type: FormFieldTypes.DROPDOWN,
required: true
});
}));
it('should be able to display label with asterix', async(() => {
const label = 'MyLabel123';
widget.field.name = label;
fixture.detectChanges();
expect(element.querySelector('label').innerText).toBe(label + '*');
}));
it('should be invalid if no default option', async(() => {
fixture.detectChanges();
expect(element.querySelector('.adf-invalid')).toBeDefined();
expect(element.querySelector('.adf-invalid')).not.toBeNull();
}));
it('should be valid if default option', async(() => {
widget.field.options = fakeOptionList;
widget.field.value = fakeOptionList[0].id;
fixture.detectChanges();
expect(element.querySelector('.adf-invalid')).toBeNull();
}));
});
describe('when template is ready', () => {
describe('and dropdown is populated via taskId', () => {