mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-25 23:50:51 +08:00
Add endpoint to list reaction types
This commit is contained in:
@@ -15,6 +15,14 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class ReactionController {
|
||||
private final ReactionService reactionService;
|
||||
|
||||
/**
|
||||
* Get all available reaction types.
|
||||
*/
|
||||
@GetMapping("/reaction-types")
|
||||
public ReactionType[] listReactionTypes() {
|
||||
return ReactionType.values();
|
||||
}
|
||||
|
||||
@PostMapping("/posts/{postId}/reactions")
|
||||
public ResponseEntity<ReactionDto> reactToPost(@PathVariable Long postId,
|
||||
@RequestBody ReactionRequest req,
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@@ -70,4 +71,11 @@ class ReactionControllerTest {
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.commentId").value(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listReactionTypes() throws Exception {
|
||||
mockMvc.perform(get("/api/reaction-types"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$[0]").value("LIKE"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user