Skip to content

Commit f78db16

Browse files
authored
test: 아이템/칭호 장착 해제 테스트 (#102)
1 parent f865167 commit f78db16

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

backend/src/test/java/com/back/domain/member/ApiV1MemberControllerTest.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
2929
import static org.hamcrest.Matchers.notNullValue;
30+
import static org.hamcrest.Matchers.nullValue;
3031
import static org.junit.jupiter.api.Assertions.assertEquals;
3132
import static org.junit.jupiter.api.Assertions.assertNotNull;
3233
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
@@ -404,6 +405,52 @@ void equipTitle() throws Exception {
404405
.andExpect(jsonPath("$.content.title").value(title2.getId()));
405406
}
406407

408+
@Test
409+
@DisplayName("아이템 장착 해제")
410+
void unequipItem() throws Exception {
411+
ResultActions resultActions = mvc
412+
.perform(
413+
put(baseUrl + "/unequip/item")
414+
.contentType(MediaType.APPLICATION_JSON)
415+
.content("""
416+
{
417+
"type": "%s"
418+
}
419+
""".formatted(item1.getType()).stripIndent())
420+
.cookie(new Cookie("apiKey", user1.getApiKey()))
421+
)
422+
.andDo(print());
423+
424+
resultActions
425+
.andExpect(handler().handlerType(ApiV1MemberController.class))
426+
.andExpect(handler().methodName("unequipItem"))
427+
.andExpect(status().isOk())
428+
.andExpect(jsonPath("$.code").value("200"))
429+
.andExpect(jsonPath("$.message").value("[Member] Success: 아이템 장착 해제 (%s)".formatted(item1.getType())))
430+
.andExpect(jsonPath("$.content").exists())
431+
.andExpect(jsonPath("$.content.items." + item1.getType()).value(nullValue()));
432+
}
433+
434+
@Test
435+
@DisplayName("칭호 장착 해제")
436+
void unequipTitle() throws Exception {
437+
ResultActions resultActions = mvc
438+
.perform(
439+
put(baseUrl + "/unequip/title")
440+
.cookie(new Cookie("apiKey", user1.getApiKey()))
441+
)
442+
.andDo(print());
443+
444+
resultActions
445+
.andExpect(handler().handlerType(ApiV1MemberController.class))
446+
.andExpect(handler().methodName("unequipTitle"))
447+
.andExpect(status().isOk())
448+
.andExpect(jsonPath("$.code").value("200"))
449+
.andExpect(jsonPath("$.message").value("[Member] Success: 칭호 장착 해제"))
450+
.andExpect(jsonPath("$.content").exists())
451+
.andExpect(jsonPath("$.content.title").value(nullValue()));
452+
}
453+
407454
@Test
408455
@DisplayName("회원 탈퇴")
409456
void del() throws Exception {

0 commit comments

Comments
 (0)