Skip to content
Myr

utils.js

This file

Path

test/utils.js

83 lines · 2.5 KiB · JavaScript

Last changed by

chore: enforce explicit Buffer import and add lint rule (#6525)Shivam Sharmabefore adoption98c85eb

History of this file

Take it

The walk stopped after 200 commits: lines older than e66625b point at it.

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

line 2why, one step back
2

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

line 3why, one step back
3var assert = require('node:assert');

chore: enforce explicit Buffer import and add lint rule (#6525)Shivam Sharmabefore adoption98c85eb

line 4why, one step back
4const { Buffer } = require('node:buffer');

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

line 5why, one step back
5var utils = require('../lib/utils');

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 6–8why, one step back
6
7describe('utils.etag(body, encoding)', function(){8 it('should support strings', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 9–10why, one step back
9 assert.strictEqual(utils.etag('express!'),
10 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 11–13why, one step back
11 })
1213 it('should support utf8 strings', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 14–15why, one step back
14 assert.strictEqual(utils.etag('express❤', 'utf8'),
15 '"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 16–18why, one step back
16 })
1718 it('should support buffer', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 19–20why, one step back
19 assert.strictEqual(utils.etag(Buffer.from('express!')),
20 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 21–23why, one step back
21 })
2223 it('should support empty string', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 24–25why, one step back
24 assert.strictEqual(utils.etag(''),
25 '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 26–27why, one step back
26 })
27})

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

line 28why, one step back
28

increased code coverage of utils.js file (#6386)Ashish Sharmabefore adoption5da5a11

lines 29–40why, one step back
29describe('utils.normalizeType acceptParams method', () => {
30 it('should handle a type with a malformed parameter and break the loop in acceptParams', () => {31 const result = utils.normalizeType('text/plain;invalid');32 assert.deepEqual(result,{33 value: 'text/plain',34 quality: 1,35 params: {} // No parameters are added since "invalid" has no "="36 });37 });38});3940

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

lines 41–61why, one step back
41describe('utils.setCharset(type, charset)', function () {
42 it('should do anything without type', function () {43 assert.strictEqual(utils.setCharset(), undefined);44 });4546 it('should return type if not given charset', function () {47 assert.strictEqual(utils.setCharset('text/html'), 'text/html');48 });4950 it('should keep charset if not given charset', function () {51 assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8');52 });5354 it('should set charset', function () {55 assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8');56 });5758 it('should override charset', function () {59 assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8');60 });61});

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 62–64why, one step back
62
63describe('utils.wetag(body, encoding)', function(){64 it('should support strings', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 65–66why, one step back
65 assert.strictEqual(utils.wetag('express!'),
66 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 67–69why, one step back
67 })
6869 it('should support utf8 strings', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 70–71why, one step back
70 assert.strictEqual(utils.wetag('express❤', 'utf8'),
71 'W/"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 72–74why, one step back
72 })
7374 it('should support buffer', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 75–76why, one step back
75 assert.strictEqual(utils.wetag(Buffer.from('express!')),
76 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 77–79why, one step back
77 })
7879 it('should support empty string', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

lines 80–81why, one step back
80 assert.strictEqual(utils.wetag(''),
81 'W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')

Remove res.send(body, status) signatureDouglas Christopher Wilsonbefore adoptione66625b

lines 82–83why, one step back
82 })
83})