test.js 996 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env node
  2. var test = require('tape')
  3. , errno = require('./')
  4. test('sanity checks', function (t) {
  5. t.ok(errno.all, 'errno.all not found')
  6. t.ok(errno.errno, 'errno.errno not found')
  7. t.ok(errno.code, 'errno.code not found')
  8. t.equal(errno.all.length, 59, 'found ' + errno.all.length + ', expected 59')
  9. t.equal(errno.errno['-1'], errno.all[0], 'errno -1 not first element')
  10. t.equal(errno.code['UNKNOWN'], errno.all[0], 'code UNKNOWN not first element')
  11. t.equal(errno.errno[1], errno.all[2], 'errno 1 not third element')
  12. t.equal(errno.code['EOF'], errno.all[2], 'code EOF not third element')
  13. t.end()
  14. })
  15. test('custom errors', function (t) {
  16. var Cust = errno.create('FooNotBarError')
  17. var cust = new Cust('foo is not bar')
  18. t.equal(cust.name, 'FooNotBarError', 'correct custom name')
  19. t.equal(cust.type, 'FooNotBarError', 'correct custom type')
  20. t.equal(cust.message, 'foo is not bar', 'correct custom message')
  21. t.notOk(cust.cause, 'no cause')
  22. t.end()
  23. })