Sha256: 389f6cdc706479afead74984d181967a1152e649e3b466c0c2f08846b9c209c2

Contents?: true

Size: 1.55 KB

Versions: 35

Compression:

Stored size: 1.55 KB

Contents

var tape = require('tape')
  , caseless = require('./')
  ;

tape('set get has', function (t) {
  var headers = {}
    , c = caseless(headers)
    ;
  t.plan(17)
  c.set('a-Header', 'asdf')
  t.equal(c.get('a-header'), 'asdf')
  t.equal(c.has('a-header'), 'a-Header')
  t.ok(!c.has('nothing'))
  // old bug where we used the wrong regex
  t.ok(!c.has('a-hea'))
  c.set('a-header', 'fdsa')
  t.equal(c.get('a-header'), 'fdsa')
  t.equal(c.get('a-Header'), 'fdsa')
  c.set('a-HEADER', 'more', false)
  t.equal(c.get('a-header'), 'fdsa,more')

  t.deepEqual(headers, {'a-Header': 'fdsa,more'})
  c.swap('a-HEADER')
  t.deepEqual(headers, {'a-HEADER': 'fdsa,more'})

  c.set('deleteme', 'foobar')
  t.ok(c.has('deleteme'))
  t.ok(c.del('deleteme'))
  t.notOk(c.has('deleteme'))
  t.notOk(c.has('idonotexist'))
  t.ok(c.del('idonotexist'))

  c.set('tva', 'test1')
  c.set('tva-header', 'test2')
  t.equal(c.has('tva'), 'tva')
  t.notOk(c.has('header'))

  t.equal(c.get('tva'), 'test1')

})

tape('swap', function (t) {
  var headers = {}
    , c = caseless(headers)
    ;
  t.plan(4)
  // No Header to Swap.
  t.throws(function () {
    c.swap('content-type')
  })
  // Set Header.
  c.set('content-type', 'application/json')
  // Swap Header With Itself.
  c.swap('content-type')
  // Does Not Delete Itself.
  t.ok(c.has('content-type'))
  // Swap Header With a Different Header.
  c.swap('Content-Type')
  // Still Has Header.
  t.ok(c.has('Content-Type'))
  // Delete Header.
  c.del('Content-Type')
  // No Header to Swap.
  t.throws(function () {
    c.swap('content-type')
  })
})

Version data entries

35 entries across 34 versions & 15 rubygems

Version Path
ezii-os-1.0.0 node_modules/caseless/test.js
ezii-os-0.0.0.1.0 node_modules/caseless/test.js
ezii-os-0.0.0.0.1 node_modules/caseless/test.js
optimacms-0.4.3 spec/dummy/node_modules/node-gyp/node_modules/caseless/test.js
optimacms-0.4.2 spec/dummy/node_modules/node-gyp/node_modules/caseless/test.js
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/caseless/test.js
lux_assets-0.2.11 ./node_modules/caseless/test.js
lux_assets-0.2.9 ./node_modules/caseless/test.js
lux_assets-0.2.4 ./node_modules/caseless/test.js
lux_assets-0.2.2 ./node_modules/caseless/test.js
lux_assets-0.2.1 ./node_modules/caseless/test.js
locomotivecms-3.4.0 app/javascript/node_modules/caseless/test.js
cortex-0.1.3 spec/dummy/node_modules/caseless/test.js
dragonfly_puppeteer-0.1.0 node_modules/caseless/test.js
affiliator-0.2.1 node_modules/fsevents/node_modules/caseless/test.js