From 6b7ccfcf120e77f20aa22ff96ccf98a994c7d35b Mon Sep 17 00:00:00 2001 From: Ayoub Mabrouk <77799760+Ayoub-Mabrouk@users.noreply.github.com> Date: Sun, 1 Feb 2026 03:53:38 +0100 Subject: [PATCH] test: add test for normalizeType fallback when mime lookup fails (#6894) 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. Co-authored-by: bjohansebas <103585995+bjohansebas@users.noreply.github.com> --- test/utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/utils.js b/test/utils.js index fbbf9fff..d1174d01 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 () {