diff --git a/src/app/main/component/comments/components/comments-list/comments-list.component.spec.ts b/src/app/main/component/comments/components/comments-list/comments-list.component.spec.ts index 4e953c2604..6c05d7f2e5 100644 --- a/src/app/main/component/comments/components/comments-list/comments-list.component.spec.ts +++ b/src/app/main/component/comments/components/comments-list/comments-list.component.spec.ts @@ -121,8 +121,12 @@ describe('CommentsListComponent', () => { }); it('should send data when user save edited content', () => { - component.content.setValue('some test text'); + component.content.setValue('Updated comment text'); + + component['commentHtml'] = 'Updated comment text'; + const spy = spyOn((component as any).commentsService, 'editComment').and.returnValue(of()); + component.saveEditedComment(commentData); expect(spy).toHaveBeenCalled(); }); diff --git a/src/app/main/component/comments/components/comments-list/comments-list.component.ts b/src/app/main/component/comments/components/comments-list/comments-list.component.ts index e7455a350e..6a7d2501a1 100644 --- a/src/app/main/component/comments/components/comments-list/comments-list.component.ts +++ b/src/app/main/component/comments/components/comments-list/comments-list.component.ts @@ -75,6 +75,12 @@ export class CommentsListComponent { } saveEditedComment(element: CommentsDTO): void { + if (!this.commentHtml.trim() || this.commentHtml === element.text) { + element.isEdit = false; + this.content.reset(); + return; + } + this.commentsService .editComment(element.id, this.commentHtml) .pipe(take(1))