Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.js 1.5KB

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