"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/caseless/test.js" (8 Mar 2017, 1585 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var tape = require('tape')
    2   , caseless = require('./')
    3   ;
    4 
    5 tape('set get has', function (t) {
    6   var headers = {}
    7     , c = caseless(headers)
    8     ;
    9   t.plan(17)
   10   c.set('a-Header', 'asdf')
   11   t.equal(c.get('a-header'), 'asdf')
   12   t.equal(c.has('a-header'), 'a-Header')
   13   t.ok(!c.has('nothing'))
   14   // old bug where we used the wrong regex
   15   t.ok(!c.has('a-hea'))
   16   c.set('a-header', 'fdsa')
   17   t.equal(c.get('a-header'), 'fdsa')
   18   t.equal(c.get('a-Header'), 'fdsa')
   19   c.set('a-HEADER', 'more', false)
   20   t.equal(c.get('a-header'), 'fdsa,more')
   21 
   22   t.deepEqual(headers, {'a-Header': 'fdsa,more'})
   23   c.swap('a-HEADER')
   24   t.deepEqual(headers, {'a-HEADER': 'fdsa,more'})
   25 
   26   c.set('deleteme', 'foobar')
   27   t.ok(c.has('deleteme'))
   28   t.ok(c.del('deleteme'))
   29   t.notOk(c.has('deleteme'))
   30   t.notOk(c.has('idonotexist'))
   31   t.ok(c.del('idonotexist'))
   32 
   33   c.set('tva', 'test1')
   34   c.set('tva-header', 'test2')
   35   t.equal(c.has('tva'), 'tva')
   36   t.notOk(c.has('header'))
   37 
   38   t.equal(c.get('tva'), 'test1')
   39 
   40 })
   41 
   42 tape('swap', function (t) {
   43   var headers = {}
   44     , c = caseless(headers)
   45     ;
   46   t.plan(4)
   47   // No Header to Swap.
   48   t.throws(function () {
   49     c.swap('content-type')
   50   })
   51   // Set Header.
   52   c.set('content-type', 'application/json')
   53   // Swap Header With Itself.
   54   c.swap('content-type')
   55   // Does Not Delete Itself.
   56   t.ok(c.has('content-type'))
   57   // Swap Header With a Different Header.
   58   c.swap('Content-Type')
   59   // Still Has Header.
   60   t.ok(c.has('Content-Type'))
   61   // Delete Header.
   62   c.del('Content-Type')
   63   // No Header to Swap.
   64   t.throws(function () {
   65     c.swap('content-type')
   66   })
   67 })