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 542B

1234567891011121314151617181920212223242526
  1. var tape = require('tape')
  2. var toBuffer = require('./')
  3. tape('buffer returns buffer', function (t) {
  4. t.same(toBuffer(Buffer('hi')), Buffer('hi'))
  5. t.end()
  6. })
  7. tape('string returns buffer', function (t) {
  8. t.same(toBuffer('hi'), Buffer('hi'))
  9. t.end()
  10. })
  11. tape('string + enc returns buffer', function (t) {
  12. t.same(toBuffer('6869', 'hex'), Buffer('hi'))
  13. t.end()
  14. })
  15. tape('other input throws', function (t) {
  16. try {
  17. toBuffer(42)
  18. } catch (err) {
  19. t.same(err.message, 'Input should be a buffer or a string')
  20. t.end()
  21. }
  22. })