Skip to content

Commit

Permalink
fix: fix auth controller test not passing
Browse files Browse the repository at this point in the history
  • Loading branch information
jjgancfer committed Mar 26, 2024
1 parent 3db326f commit 9397c71
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion api/src/test/java/lab/en2b/quizapi/auth/AuthControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lab.en2b.quizapi.auth.jwt.JwtUtils;
import lab.en2b.quizapi.commons.user.UserService;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
Expand All @@ -17,6 +18,9 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultMatcher;

import java.util.Arrays;
import java.util.List;

import static lab.en2b.quizapi.commons.utils.TestUtils.asJsonString;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
Expand All @@ -41,7 +45,14 @@ public class AuthControllerTest {
final RefreshTokenResponseDto defaultRefreshTokenResponseDto = RefreshTokenResponseDto.builder().build();
@Test
void registerUserShouldReturn200() throws Exception {
testRegister(asJsonString( new RegisterDto("[email protected]","test","testing"))
Mockito.when(authService.login(new LoginDto("[email protected]", "testing")))
.thenReturn(new JwtResponseDto("token",
"refreshToken",
0L,
"test",
"[email protected]",
List.of("user")));
testRegister(asJsonString(new RegisterDto("[email protected]","test","testing"))
,status().isOk());
}
@Test
Expand Down

0 comments on commit 9397c71

Please sign in to comment.