-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#70] feat: Article 좋아요, 좋아요취소 기능 구현 및 테스트
- Loading branch information
1 parent
9b5e55b
commit 42dbbd2
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.study.realworld.tag.domain.Tag; | ||
import com.study.realworld.user.domain.Bio; | ||
|
@@ -106,6 +108,43 @@ void deleteArticleTest() { | |
assertThat(result).isAfter(startTime).isBefore(endTime); | ||
} | ||
|
||
@Test | ||
@DisplayName("유저가 글을 좋아요할 수 있다.") | ||
void favoritingByUserTest() { | ||
|
||
// given | ||
Article article = Article.from(articleContent, author); | ||
User user = User.Builder() | ||
.email(Email.of("[email protected]")) | ||
.build(); | ||
article.favoritingByUser(user); | ||
|
||
// when | ||
boolean result = article.updateFavoritedByUser(user); | ||
|
||
// then | ||
assertTrue(result); | ||
} | ||
|
||
@Test | ||
@DisplayName("유저가 글을 좋아요 취소할 수 있다.") | ||
void unfavoritingByUserTest() { | ||
|
||
// given | ||
Article article = Article.from(articleContent, author); | ||
User user = User.Builder() | ||
.email(Email.of("[email protected]")) | ||
.build(); | ||
article.favoritingByUser(user); | ||
article.unfavoritingByUser(user); | ||
|
||
// when | ||
boolean result = article.updateFavoritedByUser(user); | ||
|
||
// then | ||
assertFalse(result); | ||
} | ||
|
||
@Test | ||
@DisplayName("equals hashCode 테스트") | ||
void articleEqualsHashCodeTest() { | ||
|