Skip to content

Commit 407dc5e

Browse files
committed
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.
1 parent 475b00c commit 407dc5e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@ describe('utils.normalizeType acceptParams method', () => {
3535
params: {} // No parameters are added since "invalid" has no "="
3636
});
3737
});
38-
});
3938

39+
it('should default to application/octet-stream when mime lookup fails', () => {
40+
const result = utils.normalizeType('unknown-extension-xyz');
41+
assert.deepEqual(result, {
42+
value: 'application/octet-stream',
43+
params: {}
44+
});
45+
});
46+
});
4047

4148
describe('utils.setCharset(type, charset)', function () {
4249
it('should do anything without type', function () {

0 commit comments

Comments
 (0)