Updated test

This commit is contained in:
delvedor
2018-12-18 17:29:06 +01:00
parent 32e674f26c
commit 7a181ff9ac
2 changed files with 15 additions and 2 deletions

View File

@ -6,7 +6,7 @@ const { URL } = require('url')
const intoStream = require('into-stream')
const { buildServer } = require('../utils')
const Connection = require('../../lib/Connection')
const { TimeoutError } = require('../../lib/errors')
const { TimeoutError, ConfigurationError } = require('../../lib/errors')
test('Basic (http)', t => {
t.plan(4)
@ -560,3 +560,16 @@ test('Connection id should not contain credentials', t => {
t.strictEqual(connection.id, 'http://localhost:9200/')
t.end()
})
test('Should throw if the protocol is not http or https', t => {
try {
new Connection({ // eslint-disable-line
url: new URL('nope://nope')
})
t.fail('Should throw')
} catch (err) {
t.ok(err instanceof ConfigurationError)
t.is(err.message, 'Invalid protocol: \'nope:\'')
}
t.end()
})