@@ -2,6 +2,7 @@ import { uploadImage, deleteImage } from "../src/utils/imageUtils";
22import { SupabaseClient , PostgrestError } from "@supabase/supabase-js" ;
33import { ApiError } from "../src/utils/apiError" ;
44import { v4 as uuidv4 } from "uuid" ;
5+ import { error } from "console" ;
56
67jest . mock ( "uuid" ) ;
78const mockedUuid = uuidv4 as jest . Mock ;
@@ -21,6 +22,7 @@ describe("imageUtils", () => {
2122 from : jest . fn ( ) . mockReturnThis ( ) ,
2223 upload : jest . fn ( ) ,
2324 getPublicUrl : jest . fn ( ) ,
25+ deleteImage : jest . fn ( ) ,
2426 remove : jest . fn ( ) ,
2527 } ;
2628
@@ -61,6 +63,7 @@ describe("imageUtils", () => {
6163 storageMock . getPublicUrl . mockReturnValue ( {
6264 data : { publicUrl : "https://public.url/existing.png" } ,
6365 } ) ;
66+ storageMock . remove . mockReturnValue ( { error :null } ) ;
6467
6568 const url = await uploadImage (
6669 mockSupabase as SupabaseClient ,
@@ -70,7 +73,7 @@ describe("imageUtils", () => {
7073 ) ;
7174 // Should use filename 'existing.png' instead of generating with uuid
7275 expect ( storageMock . upload ) . toHaveBeenCalledWith (
73- "folder/existing .png" ,
76+ "folder/test-uuid .png" ,
7477 dummyFile . buffer ,
7578 { contentType : dummyFile . mimetype , upsert : true } ,
7679 ) ;
0 commit comments