utils.js
This file
Path
test/utils.js
71 lines · 2.1 KiB · JavaScript
Last changed by
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
History of this fileTake it
The walk stopped after 200 commits: lines older than 454c4b2 point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
line 2why, one step back2Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 3why, one step back3var assert = require('assert');Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe
line 4why, one step back4var Buffer = require('safe-buffer').BufferMerge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
line 5why, one step back5var utils = require('../lib/utils');Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 6–8why, one step back67describe('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 back9 assert.strictEqual(utils.etag('express!'),10 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 11–13why, one step back11 })1213 it('should support utf8 strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 14–15why, one step back14 assert.strictEqual(utils.etag('express❤', 'utf8'),15 '"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 16–18why, one step back16 })1718 it('should support buffer', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 19–20why, one step back19 assert.strictEqual(utils.etag(Buffer.from('express!')),20 '"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 21–23why, one step back21 })2223 it('should support empty string', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 24–25why, one step back24 assert.strictEqual(utils.etag(''),25 '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 26–27why, one step back26 })27})Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710
lines 28–49why, one step back2829describe('utils.setCharset(type, charset)', function () {30 it('should do anything without type', function () {31 assert.strictEqual(utils.setCharset(), undefined);32 });3334 it('should return type if not given charset', function () {35 assert.strictEqual(utils.setCharset('text/html'), 'text/html');36 });3738 it('should keep charset if not given charset', function () {39 assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8');40 });4142 it('should set charset', function () {43 assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8');44 });4546 it('should override charset', function () {47 assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8');48 });49});Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 50–52why, one step back5051describe('utils.wetag(body, encoding)', function(){52 it('should support strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 53–54why, one step back53 assert.strictEqual(utils.wetag('express!'),54 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 55–57why, one step back55 })5657 it('should support utf8 strings', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 58–59why, one step back58 assert.strictEqual(utils.wetag('express❤', 'utf8'),59 'W/"a-JBiXf7GyzxwcrxY4hVXUwa7tmks"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 60–62why, one step back60 })6162 it('should support buffer', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 63–64why, one step back63 assert.strictEqual(utils.wetag(Buffer.from('express!')),64 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 65–67why, one step back65 })6667 it('should support empty string', function(){Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
lines 68–69why, one step back68 assert.strictEqual(utils.wetag(''),69 'W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2
lines 70–71why, one step back70 })71})