Skip to content

Commit

Permalink
#69 - 댓글 컨트롤러 테스트 업데이트: 대댓글 케이스 추가
Browse files Browse the repository at this point in the history
대댓글이 포함된 댓글 저장 api의 입출력 테스트 추가
  • Loading branch information
lmw7414 committed Jan 15, 2023
1 parent d89e933 commit 334f33b
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,27 @@ void givenArticleCommentIdToDelete_whenRequesting_thenDeletesArticleComment() th
then(articleCommentService).should().deleteArticleComment(articleCommentId, userId);
}


@WithUserDetails(value = "unoTest", setupBefore = TestExecutionEvent.TEST_EXECUTION)
@DisplayName("[view][POST] 대댓글 등록 - 정상 호출")
@Test
void givenArticleCommentInfoWithParentCommentId_whenRequesting_thenSavesNewChildComment() throws Exception {
// Given
long articleId = 1L;
ArticleCommentRequest request = ArticleCommentRequest.of(articleId, 1L, "test comment");
willDoNothing().given(articleCommentService).saveArticleComment(any(ArticleCommentDto.class));

// When & Then
mvc.perform(
post("/comments/new")
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(formDataEncoder.encode(request))
.with(csrf())
)
.andExpect(status().is3xxRedirection())
.andExpect(view().name("redirect:/articles/" + articleId))
.andExpect(redirectedUrl("/articles/" + articleId));
then(articleCommentService).should().saveArticleComment(any(ArticleCommentDto.class));
}

}

0 comments on commit 334f33b

Please sign in to comment.