Skip to content

Commit

Permalink
[#83] test : 회원 탈퇴와 닉네임 변경을 테스트 한다
Browse files Browse the repository at this point in the history
  • Loading branch information
packdev937 committed Jan 18, 2024
1 parent f0036fa commit e022c91
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/test/java/ssu/eatssu/domain/user/service/UserServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.assertj.core.api.Assertions.*;

import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -30,10 +31,45 @@ void setUp() {
@Test
void 회원가입을_한다() {
// given & when
userService.join("[email protected]", OAuthProvider.EATSSU, "1234");
회원가입_요청();

// then
assertThat(userRepository.findAll()).hasSize(1);
}

}
@Test
void 닉네임을_변경한다() {
// given
User user = 회원가입_요청();
CustomUserDetails userDetails = UserDetails_생성(user);

// when
userService.updateNickname(userDetails, new NicknameUpdateRequest("newNickname"));

// then
user = userRepository.findById(userDetails.getId()).orElseThrow();
assertThat(user.getNickname()).isEqualTo("newNickname");
}

@Test
void 회원탈퇴를_한다() {
// given
User user = 회원가입_요청();
CustomUserDetails userDetails = UserDetails_생성(user);

// when
userService.withdraw(userDetails);

// then
assertThat(userRepository.findAll()).hasSize(0);
}

private User 회원가입_요청() {
return userService.join("[email protected]", OAuthProvider.EATSSU, "1234");
}

@NotNull
private CustomUserDetails UserDetails_생성(User user) {
return new CustomUserDetails(user);
}
}

0 comments on commit e022c91

Please sign in to comment.