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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| 'use strict'
|
| const { test } = require('tap')
| const {
| LDAPError,
| ConnectionError,
| AbandonedError,
| TimeoutError,
| ConstraintViolationError,
| LDAP_OTHER
| } = require('../lib')
|
| test('basic error', function (t) {
| const msg = 'mymsg'
| const err = new LDAPError(msg, null, null)
| t.ok(err)
| t.equal(err.name, 'LDAPError')
| t.equal(err.code, LDAP_OTHER)
| t.equal(err.dn, '')
| t.equal(err.message, msg)
| t.end()
| })
|
| test('exports ConstraintViolationError', function (t) {
| const msg = 'mymsg'
| const err = new ConstraintViolationError(msg, null, null)
| t.ok(err)
| t.equal(err.name, 'ConstraintViolationError')
| t.equal(err.code, 19)
| t.equal(err.dn, '')
| t.equal(err.message, msg)
| t.end()
| })
|
| test('"custom" errors', function (t) {
| const errors = [
| { name: 'ConnectionError', Func: ConnectionError },
| { name: 'AbandonedError', Func: AbandonedError },
| { name: 'TimeoutError', Func: TimeoutError }
| ]
|
| errors.forEach(function (entry) {
| const msg = entry.name + 'msg'
| const err = new entry.Func(msg)
| t.ok(err)
| t.equal(err.name, entry.name)
| t.equal(err.code, LDAP_OTHER)
| t.equal(err.dn, '')
| t.equal(err.message, msg)
| })
|
| t.end()
| })
|
|