Skip to content
Myr

utils.js

This file

Path

test/utils.js

73 lines · 1.8 KiB · JavaScript

Last changed by

Use etag to generate ETag headersDouglas Christopher Wilsonbefore adoption51d33ed

History of this file

Take it

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

deps: send@0.7.0Douglas Christopher Wilsonbefore adoption88cffad

lines 1–30why, one step back
1
2var utils = require('../lib/utils')3 , assert = require('assert');45describe('utils.etag(body, encoding)', function(){6 it('should support strings', function(){7 utils.etag('express!')8 .should.eql('"zZdv4imtWD49AHEviejT6A=="')9 })1011 it('should support utf8 strings', function(){12 utils.etag('express❤', 'utf8')13 .should.eql('"fsFba4IxwQS6h6Umb+FNxw=="')14 })1516 it('should support buffer', function(){17 var buf = new Buffer('express!')18 utils.etag(buf)19 .should.eql('"zZdv4imtWD49AHEviejT6A=="');20 })2122 it('should support empty string', function(){23 utils.etag('')24 .should.eql('"1B2M2Y8AsgTpgAmY7PhCfg=="');25 })26})2728describe('utils.wetag(body, encoding)', function(){29 it('should support strings', function(){30 utils.wetag('express!')

Use etag to generate ETag headersDouglas Christopher Wilsonbefore adoption51d33ed

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

deps: send@0.7.0Douglas Christopher Wilsonbefore adoption88cffad

lines 32–35why, one step back
32 })
3334 it('should support utf8 strings', function(){35 utils.wetag('express❤', 'utf8')

Use etag to generate ETag headersDouglas Christopher Wilsonbefore adoption51d33ed

line 36why, one step back
36 .should.eql('W/"a-686b0af1"')

deps: send@0.7.0Douglas Christopher Wilsonbefore adoption88cffad

lines 37–41why, one step back
37 })
3839 it('should support buffer', function(){40 var buf = new Buffer('express!')41 utils.wetag(buf)

Use etag to generate ETag headersDouglas Christopher Wilsonbefore adoption51d33ed

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

deps: send@0.7.0Douglas Christopher Wilsonbefore adoption88cffad

lines 43–73why, one step back
43 })
4445 it('should support empty string', function(){46 utils.wetag('')47 .should.eql('W/"0-0"');48 })49})5051describe('utils.isAbsolute()', function(){52 it('should support windows', function(){53 assert(utils.isAbsolute('c:\\'));54 assert(!utils.isAbsolute(':\\'));55 })5657 it('should support windows unc', function(){58 assert(utils.isAbsolute('\\\\foo\\bar'))59 })6061 it('should support unices', function(){62 assert(utils.isAbsolute('/foo/bar'));63 assert(!utils.isAbsolute('foo/bar'));64 })65})6667describe('utils.flatten(arr)', function(){68 it('should flatten an array', function(){69 var arr = ['one', ['two', ['three', 'four'], 'five']];70 utils.flatten(arr)71 .should.eql(['one', 'two', 'three', 'four', 'five']);72 })73})