From 3bbbbc307f1b64ff6f5e148b350ca5697a404330 Mon Sep 17 00:00:00 2001 From: Mathis HERRIOT <197931332+0x485254@users.noreply.github.com> Date: Tue, 20 Jan 2026 09:57:11 +0100 Subject: [PATCH] test(media): fix type casting in MediaController unit tests Update type casting for `Response` object in MediaController tests to use `unknown as Response` for stricter type safety. Remove unused `s3Service` variable for cleanup. --- backend/src/media/media.controller.spec.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/media/media.controller.spec.ts b/backend/src/media/media.controller.spec.ts index 608bbcb..359a512 100644 --- a/backend/src/media/media.controller.spec.ts +++ b/backend/src/media/media.controller.spec.ts @@ -1,12 +1,12 @@ import { Readable } from "node:stream"; import { NotFoundException } from "@nestjs/common"; import { Test, TestingModule } from "@nestjs/testing"; +import type { Response } from "express"; import { S3Service } from "../s3/s3.service"; import { MediaController } from "./media.controller"; describe("MediaController", () => { let controller: MediaController; - let s3Service: S3Service; const mockS3Service = { getFileInfo: jest.fn(), @@ -20,7 +20,6 @@ describe("MediaController", () => { }).compile(); controller = module.get(MediaController); - s3Service = module.get(S3Service); }); it("should be defined", () => { @@ -31,7 +30,7 @@ describe("MediaController", () => { it("should stream the file and set headers with path containing slashes", async () => { const res = { setHeader: jest.fn(), - } as any; + } as unknown as Response; const stream = new Readable(); stream.pipe = jest.fn(); const key = "contents/user-id/test.webp"; @@ -52,7 +51,7 @@ describe("MediaController", () => { it("should throw NotFoundException if file is not found", async () => { mockS3Service.getFileInfo.mockRejectedValue(new Error("Not found")); - const res = {} as any; + const res = {} as unknown as Response; await expect(controller.getFile("invalid", res)).rejects.toThrow( NotFoundException,