Add test
This commit is contained in:
parent
3ca2c265da
commit
f9ae5c12d8
|
@ -122,9 +122,7 @@ function Client (options) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.servers = urls.map((host) => {
|
this.servers = urls.map(url.parse)
|
||||||
return url.parse(host)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// select random server at the start
|
// select random server at the start
|
||||||
|
|
|
@ -340,7 +340,7 @@ tap.test('createClient', t => {
|
||||||
t.throws(() => ldap.createClient(42), match)
|
t.throws(() => ldap.createClient(42), match)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.test('url must be a string', async t => {
|
t.test('url must be a string or array', async t => {
|
||||||
const match = /options\.url \(string\|array\) required/
|
const match = /options\.url \(string\|array\) required/
|
||||||
t.throws(() => ldap.createClient({ url: {} }), match)
|
t.throws(() => ldap.createClient({ url: {} }), match)
|
||||||
t.throws(() => ldap.createClient({ url: 42 }), match)
|
t.throws(() => ldap.createClient({ url: 42 }), match)
|
||||||
|
@ -378,6 +378,29 @@ tap.test('createClient', t => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.test('url array is correctly assigned', async t => {
|
||||||
|
getPort().then(function (unusedPortNumber) {
|
||||||
|
const client = ldap.createClient({
|
||||||
|
url: [
|
||||||
|
`ldap://0.0.0.0:${unusedPortNumber}`,
|
||||||
|
`ldap://0.0.0.1:${unusedPortNumber}`
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
t.equal(client.servers.length, 2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.test('url string is correctly parsed and assigned', async t => {
|
||||||
|
getPort().then(function (unusedPortNumber) {
|
||||||
|
const client = ldap.createClient({
|
||||||
|
url: `ldap://0.0.0.0:${unusedPortNumber},0.0.0.1:${unusedPortNumber}`
|
||||||
|
})
|
||||||
|
|
||||||
|
t.equal(client.servers.length, 2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// TODO: this test is really flaky. It would be better if we could validate
|
// TODO: this test is really flaky. It would be better if we could validate
|
||||||
// the options _withouth_ having to connect to a server.
|
// the options _withouth_ having to connect to a server.
|
||||||
// t.test('attaches a child function to logger', async t => {
|
// t.test('attaches a child function to logger', async t => {
|
||||||
|
|
Loading…
Reference in New Issue