[DSC-112] unit testing

This commit is contained in:
Alba Aliu
2021-09-24 17:07:38 +02:00
parent cbab3484e7
commit b22d8358fb
2 changed files with 62 additions and 0 deletions

View File

@@ -463,4 +463,40 @@ describe('EditInPlaceFieldComponent', () => {
});
});
describe('canEditMetadataField', () => {
describe('when the fieldUpdate\'s changeType is currently ADD', () => {
beforeEach(() => {
objectUpdatesService.isEditable.and.returnValue(observableOf(true));
comp.fieldUpdate.changeType = FieldChangeType.ADD;
fixture.detectChanges();
});
it('can edit metadata field', () => {
const disabledMetadataField = fixture.debugElement.query(By.css('ds-validation-suggestions')).componentInstance.disable
expect(disabledMetadataField).toBe(false);
});
});
describe('when the fieldUpdate\'s changeType is currently REMOVE', () => {
beforeEach(() => {
objectUpdatesService.isEditable.and.returnValue(observableOf(true));
comp.fieldUpdate.changeType = FieldChangeType.REMOVE;
fixture.detectChanges();
});
it('can edit metadata field', () => {
const disabledMetadataField = fixture.debugElement.query(By.css('ds-validation-suggestions')).componentInstance.disable
expect(disabledMetadataField).toBe(true);
});
});
describe('when the fieldUpdate\'s changeType is currently UPDATE', () => {
beforeEach(() => {
objectUpdatesService.isEditable.and.returnValue(observableOf(true));
comp.fieldUpdate.changeType = FieldChangeType.UPDATE;
fixture.detectChanges();
});
it('can edit metadata field', () => {
const disabledMetadataField = fixture.debugElement.query(By.css('ds-validation-suggestions')).componentInstance.disable
expect(disabledMetadataField).toBe(true);
});
});
});
});

View File

@@ -60,4 +60,30 @@ describe('ValidationSuggestionsComponent', () => {
expect(comp.onClickSuggestion).toHaveBeenCalledWith(suggestions[clickedIndex].value);
});
});
describe('can edit input', () => {
describe('test input field readonly property when input disable is true', () => {
beforeEach(() => {
comp.disable = true;
fixture.detectChanges();
});
it('it should be true', () => {
fixture.detectChanges();
let input = fixture.debugElement.query(By.css('input'));
let el = input.nativeElement;
expect(el.readOnly).toBe(true)
});
})
describe('test input field readonly property when input disable is false', () => {
beforeEach(() => {
comp.disable = false;
fixture.detectChanges();
});
it('it should be true', () => {
fixture.detectChanges();
let input = fixture.debugElement.query(By.css('input'));
let el = input.nativeElement;
expect(el.readOnly).toBe(false)
});
})
})
});