Skip to content
Myr

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 file

Take it

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

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

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

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

line 2why, one step back
2

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

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

Merge tag '4.16.2'Douglas Christopher Wilsonbefore adoption62e12fe

line 4why, one step back
4var Buffer = require('safe-buffer').Buffer

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

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

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

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"')

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

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"')

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

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"')

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

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"')

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

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

Merge tag '4.12.0'Douglas Christopher Wilsonbefore adoptionf6ec710

lines 28–49why, one step back
28
29describe('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.16.2'Douglas Christopher Wilsonbefore adoptione05a520

lines 50–52why, one step back
50
51describe('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 back
53 assert.strictEqual(utils.wetag('express!'),
54 'W/"8-O2uVAFaQ1rZvlKLT14RnuvjPIdg"')

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

lines 55–57why, one step back
55 })
5657 it('should support utf8 strings', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

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

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

lines 60–62why, one step back
60 })
6162 it('should support buffer', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

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

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

lines 65–67why, one step back
65 })
6667 it('should support empty string', function(){

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

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

Merge tag '3.16.2'Douglas Christopher Wilsonbefore adoptione05a520

lines 70–71why, one step back
70 })
71})