[Backport 7.x] The agent function should take the Connection contructor options as argument (#1334)
Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
34dedb8119
commit
dd8ee9056b
@ -20,22 +20,35 @@
|
||||
import { expectType } from 'tsd'
|
||||
import { URL } from 'url'
|
||||
import { Connection } from '../../'
|
||||
import { ConnectionOptions } from '../../lib/Connection'
|
||||
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
ssl: { ca: 'string' },
|
||||
id: 'id',
|
||||
headers: {},
|
||||
agent: { keepAlive: false },
|
||||
status: 'alive',
|
||||
roles: { master: true },
|
||||
auth: { username: 'username', password: 'password' }
|
||||
})
|
||||
{
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
ssl: { ca: 'string' },
|
||||
id: 'id',
|
||||
headers: {},
|
||||
agent: { keepAlive: false },
|
||||
status: 'alive',
|
||||
roles: { master: true },
|
||||
auth: { username: 'username', password: 'password' }
|
||||
})
|
||||
|
||||
expectType<Connection>(conn)
|
||||
expectType<URL>(conn.url)
|
||||
expectType<string>(conn.id)
|
||||
expectType<Record<string, any>>(conn.headers)
|
||||
expectType<number>(conn.deadCount)
|
||||
expectType<number>(conn.resurrectTimeout)
|
||||
expectType<string>(conn.status)
|
||||
expectType<Connection>(conn)
|
||||
expectType<URL>(conn.url)
|
||||
expectType<string>(conn.id)
|
||||
expectType<Record<string, any>>(conn.headers)
|
||||
expectType<number>(conn.deadCount)
|
||||
expectType<number>(conn.resurrectTimeout)
|
||||
expectType<string>(conn.status)
|
||||
}
|
||||
|
||||
{
|
||||
const conn = new Connection({
|
||||
url: new URL('http://localhost:9200'),
|
||||
agent (opts) {
|
||||
expectType<ConnectionOptions>(opts)
|
||||
return 'the agent'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user