utils.js
This file
Path
test/utils.js
82 lines · 2.5 KiB · JavaScript
Last changed by
increased code coverage of utils.js file (#6386)Ashish Sharmabefore adoption5da5a11
History of this fileTake it
The walk stopped after 200 commits: lines older than 2c14096 point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
line 2why, one step back2fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 3why, one step back3var assert = require('node:assert');Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 4why, one step back4var utils = require('../lib/utils');deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 5–7why, one step back56describe('utils.etag(body, encoding)', function(){7 it('should support strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 8–9why, one step back8 assert.strictEqual(utils.etag('express!'),9 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 10–12why, one step back10 })1112 it('should support utf8 strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 13–14why, one step back13 assert.strictEqual(utils.etag('express❤', 'utf8'),14 '"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 15–17why, one step back15 })1617 it('should support buffer', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 18–19why, one step back18 assert.strictEqual(utils.etag(Buffer.from('express!')),19 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 20–22why, one step back20 })2122 it('should support empty string', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 23–24why, one step back23 assert.strictEqual(utils.etag(''),24 '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 25–26why, one step back25 })26})Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 27why, one step back27increased code coverage of utils.js file (#6386)Ashish Sharmabefore adoption5da5a11
lines 28–39why, one step back28describe('utils.normalizeType acceptParams method', () => {29 it('should handle a type with a malformed parameter and break the loop in acceptParams', () => {30 const result = utils.normalizeType('text/plain;invalid');31 assert.deepEqual(result,{32 value: 'text/plain',33 quality: 1,34 params: {} // No parameters are added since "invalid" has no "="35 });36 });37});3839Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
lines 40–60why, one step back40describe('utils.setCharset(type, charset)', function () {41 it('should do anything without type', function () {42 assert.strictEqual(utils.setCharset(), undefined);43 });4445 it('should return type if not given charset', function () {46 assert.strictEqual(utils.setCharset('text/html'), 'text/html');47 });4849 it('should keep charset if not given charset', function () {50 assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8');51 });5253 it('should set charset', function () {54 assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8');55 });5657 it('should override charset', function () {58 assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8');59 });60});deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 61–63why, one step back6162describe('utils.wetag(body, encoding)', function(){63 it('should support strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 64–65why, one step back64 assert.strictEqual(utils.wetag('express!'),65 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 66–68why, one step back66 })6768 it('should support utf8 strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 69–70why, one step back69 assert.strictEqual(utils.wetag('express❤', 'utf8'),70 'W/"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 71–73why, one step back71 })7273 it('should support buffer', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 74–75why, one step back74 assert.strictEqual(utils.wetag(Buffer.from('express!')),75 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 76–78why, one step back76 })7778 it('should support empty string', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 79–80why, one step back79 assert.strictEqual(utils.wetag(''),80 'W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')deps: accepts@~1.1.1Douglas Christopher Wilsonbefore adoption2c14096
lines 81–82why, one step back81 })82})