fix(TransportRequestPromise): add finally method to TransportRequestP… (#1415)

* fix(TransportRequestPromise): add finally method to TransportRequestPromise interface

* fix(TransportRequestPromise): add finally method to transportReturn object

* fix(TransportRequestPromise): add finally method tests
This commit is contained in:
Yahia Kerim
2021-03-22 11:50:15 +01:00
committed by GitHub
parent 6a30cd9955
commit ab3e809fc2
3 changed files with 31 additions and 0 deletions

View File

@ -124,6 +124,33 @@ test('Error (promises)', t => {
})
})
test('Finally method (promises)', t => {
t.plan(1)
function handler (req, res) {
res.setHeader('Content-Type', 'application/json;utf=8')
res.end(JSON.stringify({ hello: 'world' }))
}
buildServer(handler, ({ port }, server) => {
const client = new Client({
node: `http://localhost:${port}`
})
const request = client.search({
index: 'test',
q: 'foo:bar'
})
t.type(request.finally, 'function')
request
.finally(() => {
server.stop()
})
})
})
test('Abort method (callback)', t => {
t.plan(3)