Skip to content

Commit

Permalink
test: add VoiceCommentEvent test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji-soo708 authored and Kwon770 committed Dec 22, 2024
1 parent 3cc0e26 commit 28ee9ec
Showing 1 changed file with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class FamilyScoreEventListenerTest {
@Autowired
private CommentRepository commentRepository;

@Autowired
private VoiceCommentRepository voiceCommentRepository;

@Autowired
private ReactionRepository reactionRepository;

Expand Down Expand Up @@ -211,6 +214,80 @@ void setUp() {
});
}

@Test
void 새로운_음성댓글이_달리면_가족_점수를_더한다() {
// given
Post post = postRepository.save(new Post(
"1",
testMember1.getId(),
testMember1.getFamilyId(),
PostType.SURVIVAL,
"https://storage.com/images/1",
"images/1",
"1"
));

int originScore = NEW_POST_SCORE;

// when
voiceCommentRepository.save(new VoiceComment(
"1",
post,
testMember1.getId(),
"https://storage.com/audios/1"
));
voiceCommentRepository.save(new VoiceComment(
"2",
post,
testMember1.getId(),
"https://storage.com/audios/2"
));

// then
await().atMost(5, SECONDS).until(() -> {
Integer newScore = familyRepository.findById(testMember1.getFamilyId()).get().getScore();
return newScore.equals(originScore + NEW_VOICE_COMMENT_SCORE * 2);
});
}

@Test
void 음성댓글이_지워지면_가족_점수를_뺀다() {
// given
Post post = postRepository.save(new Post(
"1",
testMember1.getId(),
testMember1.getFamilyId(),
PostType.SURVIVAL,
"https://storage.com/images/1",
"images/1",
"1"
));
voiceCommentRepository.save(new VoiceComment(
"1",
post,
testMember1.getId(),
"https://storage.com/audios/1"
));
voiceCommentRepository.save(new VoiceComment(
"2",
post,
testMember1.getId(),
"https://storage.com/audios/2"
));

int originScore = NEW_POST_SCORE + (NEW_VOICE_COMMENT_SCORE * 2);

// when
voiceCommentRepository.deleteById("1");
voiceCommentRepository.deleteById("2");

// then
await().atMost(5, SECONDS).until(() -> {
Integer newScore = familyRepository.findById(testMember1.getFamilyId()).get().getScore();
return newScore.equals(originScore - (NEW_VOICE_COMMENT_SCORE * 2));
});
}

@Test
void 새로운_리액션이_달리면_가족_점수를_더한다() {
// given
Expand Down

0 comments on commit 28ee9ec

Please sign in to comment.