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
optimacms-0.1.61 spec/dummy/node_modules/caseless/test.js
disco_app-0.18.0 test/dummy/node_modules/caseless/test.js
disco_app-0.18.2 test/dummy/node_modules/caseless/test.js
tang-0.2.1 spec/tang_app/node_modules/caseless/test.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/caseless/test.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/caseless/test.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/caseless/test.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/caseless/test.js
tang-0.2.0 spec/tang_app/node_modules/caseless/test.js
tang-0.1.0 spec/tang_app/node_modules/caseless/test.js
tang-0.0.9 spec/tang_app/node_modules/caseless/test.js
enju_library-0.3.8 spec/dummy/node_modules/caseless/test.js
ilog-0.4.1 node_modules/caseless/test.js
ilog-0.4.0 node_modules/caseless/test.js
ilog-0.3.3 node_modules/caseless/test.js
learn_create-0.0.22 lib/templates/javascript_lab_template/node_modules/caseless/test.js
jester-data-8.0.0 node_modules/caseless/test.js
ezii-os-5.2.1 node_modules/caseless/test.js
ezii-os-2.0.1 node_modules/caseless/test.js
ezii-os-1.1.0 node_modules/caseless/test.js