[helpers] add support for transport options to all helpers (#1400)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer
2021-02-18 07:33:08 -08:00
committed by delvedor
parent e1d7134398
commit 5a25b7cba2
4 changed files with 112 additions and 8 deletions

View File

@ -756,3 +756,42 @@ test('Stop should resolve the helper (error)', t => {
m.then(() => t.fail('Should not fail'), err => t.is(err.message, 'kaboom'))
})
test('Should use req options', async t => {
t.plan(1)
const MockConnection = connection.buildMockConnection({
onRequest (params) {
t.match(params.headers, {
foo: 'bar'
})
return {
body: {
responses: [{
status: 200,
hits: { hits: [] }
}]
}
}
}
})
const client = new Client({
node: 'http://localhost:9200',
Connection: MockConnection
})
const m = client.helpers.msearch({ operations: 1 }, {
headers: {
foo: 'bar'
}
})
await m.search(
{ index: 'test' },
{ query: { match: { foo: 'bar' } } }
)
t.teardown(() => m.stop())
})