v1.0.0 #28
|
@ -3,7 +3,7 @@ import imageService from "../services/ImageService";
|
|||
import mongoose, { mongo } from "mongoose";
|
||||
|
||||
class ImageController {
|
||||
async getAllImages(req: Request, res: Response): Promise<void> {
|
||||
async getAllImages(_: Request, res: Response): Promise<void> {
|
||||
try {
|
||||
const images = await imageService.findAll();
|
||||
res.json({ images });
|
||||
|
|
|
@ -83,6 +83,21 @@ describe("GET /images works properly", async () => {
|
|||
it("should return a 200", async () => {
|
||||
expect(res.statusCode).toBe(200);
|
||||
});
|
||||
|
||||
it("should return 500 for an error on the service", async () => {
|
||||
mock.module("../src/services/ImageService", () => ({
|
||||
default: {
|
||||
add: () => {
|
||||
throw new Error("This is an expected testing error");
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const res = await request(app)
|
||||
.get("/images");
|
||||
|
||||
expect(res.status).toBe(500);
|
||||
});
|
||||
});
|
||||
|
||||
describe("POST /images works properly", () => {
|
||||
|
|
Loading…
Reference in New Issue