Skip to content
Myr

utils.js

This file

Path

test/utils.js

95 lines · 2.3 KiB · JavaScript

Last changed by

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

History of this file

Take it

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

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

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

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 5–12why, one step back
5describe('utils.deprecate(fn, msg)', function(){
6 var env7 before(function(){8 env = process.env.NODE_ENV9 })10 after(function(){11 process.env.NODE_ENV = env12 })

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

line 13why, one step back
13

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 14–18why, one step back
14 it('should pass-through fn in test environment', function(){
15 var fn = function(){}16 process.env.NODE_ENV = 'test'17 utils.deprecate(fn).should.equal(fn)18 })

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

line 19why, one step back
19

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 20–27why, one step back
20 it('should return new fn in other environment', function(){
21 var fn = function(){}22 process.env.NODE_ENV = ''23 utils.deprecate(fn).should.not.equal(fn)24 })25})2627describe('utils.etag(body, encoding)', function(){

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

line 28why, one step back
28 it('should support strings', function(){

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 29–30why, one step back
29 utils.etag('express!')
30 .should.eql('"zZdv4imtWD49AHEviejT6A=="')

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 31–33why, one step back
31 })
3233 it('should support utf8 strings', function(){

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 34–35why, one step back
34 utils.etag('express❤', 'utf8')
35 .should.eql('"fsFba4IxwQS6h6Umb+FNxw=="')

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 36–38why, one step back
36 })
3738 it('should support buffer', function(){

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 39–41why, one step back
39 var buf = new Buffer('express!')
40 utils.etag(buf)41 .should.eql('"zZdv4imtWD49AHEviejT6A=="');

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 42–43why, one step back
42 })
43

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 44–47why, one step back
44 it('should support empty string', function(){
45 utils.etag('')46 .should.eql('"1B2M2Y8AsgTpgAmY7PhCfg=="');47 })

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 48–49why, one step back
48})
49

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 50–72why, one step back
50describe('utils.wetag(body, encoding)', function(){
51 it('should support strings', function(){52 utils.wetag('express!')53 .should.eql('W/"8-3098196679"')54 })5556 it('should support utf8 strings', function(){57 utils.wetag('express❤', 'utf8')58 .should.eql('W/"a-1751845617"')59 })6061 it('should support buffer', function(){62 var buf = new Buffer('express!')63 utils.wetag(buf)64 .should.eql('W/"8-3098196679"');65 })6667 it('should support empty string', function(){68 utils.wetag('')69 .should.eql('W/"0-0"');70 })71})72

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 73–78why, one step back
73describe('utils.isAbsolute()', function(){
74 it('should support windows', function(){75 assert(utils.isAbsolute('c:\\'));76 assert(!utils.isAbsolute(':\\'));77 })78

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 79–83why, one step back
79 it('should support windows unc', function(){
80 assert(utils.isAbsolute('\\\\foo\\bar'))81 })8283 it('should support unices', function(){

refactor signed cookie testsTJ Holowaychukbefore adoption9fb6615

lines 84–95why, one step back
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})