From 78b988041bf7675dfcea808842fd6af2268c9fb4 Mon Sep 17 00:00:00 2001 From: Anastasia <155824290+kryzanivska-nastya@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:54:59 +0200 Subject: [PATCH] fixed --- .../comments-list/comments-list.component.spec.ts | 6 +++++- .../components/comments-list/comments-list.component.ts | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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))