[ACS-5645] added test cases for tags component

This commit is contained in:
Yasa-Nataliya
2023-10-13 16:27:31 +05:30
committed by Anukriti Singh
parent a5c4fb9ecd
commit 52acd0a216
3 changed files with 32 additions and 4 deletions
@@ -240,16 +240,16 @@ describe('CategoriesManagementComponent', () => {
}); });
}); });
describe('isEmpty', () => { describe('isCategoryEmpty', () => {
it('should return true when categories is not empty', () => { it('should return true when categories is not empty', () => {
component.categories = [category3, category4]; component.categories = [category3, category4];
const result = component.isEmpty; const result = component.isCategoryEmpty;
expect(result).toBeTrue(); expect(result).toBeTrue();
}); });
it('should return false when categories is empty', () => { it('should return false when categories is empty', () => {
component.categories = []; component.categories = [];
const result = component.isEmpty; const result = component.isCategoryEmpty;
expect(result).toBeFalse(); expect(result).toBeFalse();
}); });
}); });
@@ -322,6 +322,34 @@ describe('TagsCreatorComponent', () => {
expect(getNameInput()).toBe(document.activeElement as HTMLInputElement); expect(getNameInput()).toBe(document.activeElement as HTMLInputElement);
})); }));
describe('isNameTagsVisible', () => {
it('should return true when tagNameControlVisible is true', () => {
component.tagNameControlVisible = true;
const result = component.isNameTagsVisible;
expect(result).toBeTrue();
});
it('should return false when tagNameControlVisible is false and tags length is 0', () => {
component.tagNameControlVisible = false;
component.tags = [];
const result = component.isNameTagsVisible;
expect(result).toBeFalse();
});
});
describe('isTagsEmpty', () => {
it('should return true when tags is not empty', () => {
component.tags = ['new tag 1', 'new tag 2'];
const result = component.isTagsEmpty;
expect(result).toBeTrue();
});
it('should return false when tags is empty', () => {
component.tags = [];
const result = component.isTagsEmpty;
expect(result).toBeFalse();
});
});
describe('Errors', () => { describe('Errors', () => {
/** /**
* Get first error * Get first error
@@ -104,7 +104,7 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
if (tagNameControlVisible) { if (tagNameControlVisible) {
this._existingTagsPanelVisible = true; this._existingTagsPanelVisible = true;
setTimeout(() => { setTimeout(() => {
this.tagNameInputElement.nativeElement.scrollIntoView(); this.tagNameInputElement?.nativeElement?.scrollIntoView();
}); });
} else { } else {
this._existingTagsPanelVisible = false; this._existingTagsPanelVisible = false;