Skip to content

Commit

Permalink
test: 단위 테스트, e2e 테스트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyu0218 committed Nov 21, 2024
1 parent 5564d24 commit 5c478f4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.nexters.goalpanzi.domain.member.Member;
import com.nexters.goalpanzi.domain.member.repository.MemberRepository;
import com.nexters.goalpanzi.presentation.auth.dto.GoogleLoginRequest;
import com.nexters.goalpanzi.presentation.member.dto.UpdateDeviceTokenRequest;
import com.nexters.goalpanzi.presentation.member.dto.UpdateProfileRequest;
import com.nexters.goalpanzi.presentation.member.dto.UpdatePushActivationStatusRequest;
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -71,4 +73,38 @@ public class MemberAcceptanceTest extends AcceptanceTest {

assertThat(memberRepository.findByIdAndDeletedAtIsNull(login.memberId())).isEmpty();
}

@Test
void 디바이스_토큰을_갱신한다() {
LoginResponse login = 구글_로그인(new GoogleLoginRequest(EMAIL_HOST)).as(LoginResponse.class);

UpdateDeviceTokenRequest request = new UpdateDeviceTokenRequest(DEVICE_TOKEN);
RestAssured.given().log().all()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.AUTHORIZATION, BEARER + login.accessToken())
.body(request)
.when().patch("/api/member/device-token")
.then().log().all()
.statusCode(HttpStatus.OK.value());

Member member = memberRepository.getMember(login.memberId());
assertThat(member.getDeviceToken()).isEqualTo(DEVICE_TOKEN);
}

@Test
void 푸시_알림_활성화_여부를_수정한다() {
LoginResponse login = 구글_로그인(new GoogleLoginRequest(EMAIL_HOST)).as(LoginResponse.class);

UpdatePushActivationStatusRequest request = new UpdatePushActivationStatusRequest(true);
RestAssured.given().log().all()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.AUTHORIZATION, BEARER + login.accessToken())
.body(request)
.when().patch("/api/member/push-activation-status")
.then().log().all()
.statusCode(HttpStatus.OK.value());

Member member = memberRepository.getMember(login.memberId());
assertThat(member.isPushActivated()).isTrue();
}
}
16 changes: 16 additions & 0 deletions src/test/java/com/nexters/goalpanzi/domain/member/MemberTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ class MemberTest {

assertThat(member.isProfileSet()).isFalse();
}

@Test
void 디바이스_토큰을_갱신한다() {
Member member = Member.socialLogin(SOCIAL_ID, EMAIL_HOST, SocialType.APPLE);
member.updateDeviceToken(DEVICE_TOKEN);

assertThat(member.getDeviceToken()).isEqualTo(DEVICE_TOKEN);
}

@Test
void 푸시_알림_활성화_여부를_수정한다() {
Member member = Member.socialLogin(SOCIAL_ID, EMAIL_HOST, SocialType.APPLE);
member.updatePushActivationStatus(true);

assertThat(member.isPushActivated()).isTrue();
}
}

0 comments on commit 5c478f4

Please sign in to comment.