[ACS-5645] added test cases for tags component

This commit is contained in:
Yasa-Nataliya
2023-10-09 20:22:06 +05:30
parent c216d5f2b7
commit 358cbfeb65
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', () => {
component.categories = [category3, category4];
const result = component.isEmpty;
const result = component.isCategoryEmpty;
expect(result).toBeTrue();
});
it('should return false when categories is empty', () => {
component.categories = [];
const result = component.isEmpty;
const result = component.isCategoryEmpty;
expect(result).toBeFalse();
});
});
@@ -322,6 +322,34 @@ describe('TagsCreatorComponent', () => {
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', () => {
/**
* Get first error
@@ -104,7 +104,7 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
if (tagNameControlVisible) {
this._existingTagsPanelVisible = true;
setTimeout(() => {
this.tagNameInputElement.nativeElement.scrollIntoView();
this.tagNameInputElement?.nativeElement?.scrollIntoView();
});
} else {
this._existingTagsPanelVisible = false;