Skip to content
Myr

utils.js

This file

Path

test/utils.js

96 lines · 2.7 KiB · JavaScript

Last changed by

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

History of this file

Take it

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

lines 1–7why, one step back
1
2var assert = require('assert');3var utils = require('../lib/utils');45describe('utils.etag(body, encoding)', function(){6 it('should support strings', function(){7 utils.etag('express!')

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

line 24why, one step back
24 .should.eql('"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

lines 25–52why, one step back
25 })
26})2728describe('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});4950describe('utils.wetag(body, encoding)', function(){51 it('should support strings', function(){52 utils.wetag('express!')

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

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

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

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

deps: etag@~1.8.0Douglas Christopher Wilsonbefore adoption9f4dbae

line 69why, one step back
69 .should.eql('W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

lines 70–75why, one step back
70 })
71})7273describe('utils.isAbsolute()', function(){74 it('should support windows', function(){75 assert(utils.isAbsolute('c:\\'));

Fix Windows absolute path check using forward slasheshuaoguobefore adoption2e1284b

line 76why, one step back
76 assert(utils.isAbsolute('c:/'));

build: support io.js 3.xDouglas Christopher Wilsonbefore adoption963d795

lines 77–96why, one step back
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']];93 utils.flatten(arr)94 .should.eql(['one', 'two', 'three', 'four', 'five']);95 })96})