···452 expect(result).toBeNull();
453 });
454455- test("should handle errors when file is missing", async () => {
456- try {
457- await getImageSize("/path/to/missing.jpg");
458- // If we reach here, the test should fail
459- expect(true).toBe(false);
460- } catch (error) {
461- expect(error).toBeDefined();
462- expect((error as Error).message).toContain("Input file is missing");
463- }
000000464 });
465});
···452 expect(result).toBeNull();
453 });
454455+ test("should log error when image processing fails", async () => {
456+ // Import the logger mock
457+ const { logger } = require("../logger/logger");
458+459+ // Call the function with a path that will trigger an error
460+ const result = await getImageSize("/path/to/missing.jpg");
461+462+ // Verify the logger.error was called with the expected message pattern
463+ expect(logger.error).toHaveBeenCalled();
464+ expect(logger.error).toHaveBeenCalledWith(
465+ expect.stringMatching(/Failed to get image aspect ratio; image path: \/path\/to\/missing\.jpg, error:/)
466+ );
467+468+ // Verify the function returns null when an error occurs
469+ expect(result).toBeNull();
470 });
471});