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 <[email protected]>
This commit is contained in:
Ayoub Mabrouk
2026-01-31 21:53:38 -05:00
committed by GitHub
co-authored by bjohansebas
parent c0680401b6
commit f0390fb7ed
+8 -1
View File
@@ -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 () {