From eeaf6bc72f3a2fcb9aac0c5e6ba7088d435a2811 Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Thu, 13 Mar 2025 13:25:46 +0530 Subject: [PATCH] increased code coverage of utils.js file --- test/utils.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/utils.js b/test/utils.js index d1142266ac4..b11b26680bd 100644 --- a/test/utils.js +++ b/test/utils.js @@ -25,6 +25,18 @@ describe('utils.etag(body, encoding)', function(){ }) }) +describe('utils.normalizeType acceptParams method', () => { + it('should handle a type with a malformed parameter and break the loop in acceptParams', () => { + const result = utils.normalizeType('text/plain;invalid'); + assert.deepEqual(result,{ + value: 'text/plain', + quality: 1, + params: {} // No parameters are added since "invalid" has no "=" + }); + }); +}); + + describe('utils.setCharset(type, charset)', function () { it('should do anything without type', function () { assert.strictEqual(utils.setCharset(), undefined);