Skip to content
Myr

utils.js

This file

Path

test/utils.js

95 lines · 2.6 KiB · JavaScript

Last changed by

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

History of this file

Take it

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

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

line 1why, one step back
1

tests: add extra setCharset testsDouglas Christopher Wilsonbefore adoption53e5991

lines 2–3why, one step back
2var assert = require('assert');
3var utils = require('../lib/utils');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

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

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 8why, one step back
8 .should.eql('"8-zZdv4imtWD49AHEviejT6A"')

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 9–12why, one step back
9 })
1011 it('should support utf8 strings', function(){12 utils.etag('express❤', 'utf8')

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 13why, one step back
13 .should.eql('"a-fsFba4IxwQS6h6Umb+FNxw"')

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 14–18why, one step back
14 })
1516 it('should support buffer', function(){17 var buf = new Buffer('express!')18 utils.etag(buf)

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 19why, one step back
19 .should.eql('"8-zZdv4imtWD49AHEviejT6A"');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 20–23why, one step back
20 })
2122 it('should support empty string', function(){23 utils.etag('')

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 24why, one step back
24 .should.eql('"0-1B2M2Y8AsgTpgAmY7PhCfg"');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

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

tests: add extra setCharset testsDouglas Christopher Wilsonbefore adoption53e5991

lines 27–48why, one step back
27
28describe('utils.setCharset(type, charset)', function () {29 it('should do anything without type', function () {30 assert.strictEqual(utils.setCharset(), undefined);31 });3233 it('should return type if not given charset', function () {34 assert.strictEqual(utils.setCharset('text/html'), 'text/html');35 });3637 it('should keep charset if not given charset', function () {38 assert.strictEqual(utils.setCharset('text/html; charset=utf-8'), 'text/html; charset=utf-8');39 });4041 it('should set charset', function () {42 assert.strictEqual(utils.setCharset('text/html', 'utf-8'), 'text/html; charset=utf-8');43 });4445 it('should override charset', function () {46 assert.strictEqual(utils.setCharset('text/html; charset=iso-8859-1', 'utf-8'), 'text/html; charset=utf-8');47 });48});

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 49–52why, one step back
49
50describe('utils.wetag(body, encoding)', function(){51 it('should support strings', function(){52 utils.wetag('express!')

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 53why, one step back
53 .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"')

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 54–57why, one step back
54 })
5556 it('should support utf8 strings', function(){57 utils.wetag('express❤', 'utf8')

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 58why, one step back
58 .should.eql('W/"a-fsFba4IxwQS6h6Umb+FNxw"')

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 59–63why, one step back
59 })
6061 it('should support buffer', function(){62 var buf = new Buffer('express!')63 utils.wetag(buf)

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 64why, one step back
64 .should.eql('W/"8-zZdv4imtWD49AHEviejT6A"');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

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

Merge tag '3.21.0'Douglas Christopher Wilsonbefore adoption3d2ecdd

line 69why, one step back
69 .should.eql('W/"0-1B2M2Y8AsgTpgAmY7PhCfg"');

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 70–95why, one step back
70 })
71})7273describe('utils.isAbsolute()', function(){74 it('should support windows', function(){75 assert(utils.isAbsolute('c:\\'));76 assert(!utils.isAbsolute(':\\'));77 })7879 it('should support windows unc', function(){80 assert(utils.isAbsolute('\\\\foo\\bar'))81 })8283 it('should support unices', function(){84 assert(utils.isAbsolute('/foo/bar'));85 assert(!utils.isAbsolute('foo/bar'));86 })87})8889describe('utils.flatten(arr)', function(){90 it('should flatten an array', function(){91 var arr = ['one', ['two', ['three', 'four'], 'five']];92 utils.flatten(arr)93 .should.eql(['one', 'two', 'three', 'four', 'five']);94 })95})