summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/worker-farm/node_modules/errno/test.js
blob: 6b76a85ae1bba2864be141748a6aed18cfedd1c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node

var test  = require('tape')
  , errno = require('./')

test('sanity checks', function (t) {
  t.ok(errno.all, 'errno.all not found')
  t.ok(errno.errno, 'errno.errno not found')
  t.ok(errno.code, 'errno.code not found')

  t.equal(errno.all.length, 59, 'found ' + errno.all.length + ', expected 59')
  t.equal(errno.errno['-1'], errno.all[0], 'errno -1 not first element')

  t.equal(errno.code['UNKNOWN'], errno.all[0], 'code UNKNOWN not first element')

  t.equal(errno.errno[1], errno.all[2], 'errno 1 not third element')

  t.equal(errno.code['EOF'], errno.all[2], 'code EOF not third element')
  t.end()
})

test('custom errors', function (t) {
  var Cust = errno.create('FooNotBarError')
  var cust = new Cust('foo is not bar')

  t.equal(cust.name, 'FooNotBarError', 'correct custom name')
  t.equal(cust.type, 'FooNotBarError', 'correct custom type')
  t.equal(cust.message, 'foo is not bar', 'correct custom message')
  t.notOk(cust.cause, 'no cause')
  t.end()
})