From 38c18c8c9b84e6f6bfe93d849364632f25b608d0 Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Mon, 10 Nov 2025 23:26:33 +0100 Subject: [PATCH] test: add test for normalizeType fallback when mime lookup fails Add test to verify that utils.normalizeType correctly defaults to 'application/octet-stream' when mime.lookup() returns null/undefined for unknown file extensions. This covers the fallback behavior on line 64 of lib/utils.js and ensures proper handling of unrecognized MIME types. --- test/utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/utils.js b/test/utils.js index 1c06036aa98..0cfb7106e58 100644 --- a/test/utils.js +++ b/test/utils.js @@ -35,8 +35,15 @@ describe('utils.normalizeType acceptParams method', () => { params: {} // No parameters are added since "invalid" has no "=" }); }); -}); + it('should default to application/octet-stream when mime lookup fails', () => { + const result = utils.normalizeType('unknown-extension-xyz'); + assert.deepEqual(result, { + value: 'application/octet-stream', + params: {} + }); + }); +}); describe('utils.setCharset(type, charset)', function () { it('should do anything without type', function () {