| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | var tape = require('tape') |
| 2 | var toBuffer = require('./') |
| 3 | |
| 4 | tape('buffer returns buffer', function (t) { |
| 5 | t.same(toBuffer(Buffer('hi')), Buffer('hi')) |
| 6 | t.end() |
| 7 | }) |
| 8 | |
| 9 | tape('string returns buffer', function (t) { |
| 10 | t.same(toBuffer('hi'), Buffer('hi')) |
| 11 | t.end() |
| 12 | }) |
| 13 | |
| 14 | tape('string + enc returns buffer', function (t) { |
| 15 | t.same(toBuffer('6869', 'hex'), Buffer('hi')) |
| 16 | t.end() |
| 17 | }) |
| 18 | |
| 19 | tape('other input throws', function (t) { |
| 20 | try { |
| 21 | toBuffer(42) |
| 22 | } catch (err) { |
| 23 | t.same(err.message, 'Input should be a buffer or a string') |
| 24 | t.end() |
| 25 | } |
| 26 | }) |