Skip to content
Myr

utils.js

This file

Path

test/utils.js

103 lines · 3.0 KiB · JavaScript

Last changed by

tests: remove usage of shouldDouglas Christopher Wilsonbefore adoptionbc5ca05

History of this file

Take it

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

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 2–8why, one step back
2
3var assert = require('assert');4var Buffer = require('safe-buffer').Buffer5var utils = require('../lib/utils');67describe('utils.etag(body, encoding)', function(){8 it('should support strings', function(){

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 26–52why, one step back
26 })
27})2829describe('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});5051describe('utils.wetag(body, encoding)', function(){52 it('should support strings', function(){

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

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

tests: remove global dependency on shouldDouglas Christopher Wilsonbefore adoptionbd4fdfe

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

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 70–92why, one step back
70 })
71})7273describe('utils.isAbsolute()', function(){74 it('should support windows', function(){75 assert(utils.isAbsolute('c:\\'));76 assert(utils.isAbsolute('c:/'));77 assert(!utils.isAbsolute(':\\'));78 })7980 it('should support windows unc', function(){81 assert(utils.isAbsolute('\\\\foo\\bar'))82 })8384 it('should support unices', function(){85 assert(utils.isAbsolute('/foo/bar'));86 assert(!utils.isAbsolute('foo/bar'));87 })88})8990describe('utils.flatten(arr)', function(){91 it('should flatten an array', function(){92 var arr = ['one', ['two', ['three', 'four'], 'five']];

tests: remove usage of shouldDouglas Christopher Wilsonbefore adoptionbc5ca05

lines 93–101why, one step back
93 var flat = utils.flatten(arr)
9495 assert.strictEqual(flat.length, 5)96 assert.strictEqual(flat[0], 'one')97 assert.strictEqual(flat[1], 'two')98 assert.strictEqual(flat[2], 'three')99 assert.strictEqual(flat[3], 'four')100 assert.strictEqual(flat[4], 'five')101 assert.ok(flat.every(function (v) { return typeof v === 'string' }))

deps: finalhandler@1.1.1Douglas Christopher Wilsonbefore adoption76bf96e

lines 102–103why, one step back
102 })
103})