Updated test

This commit is contained in:
delvedor
2018-11-09 17:17:05 +01:00
parent 3dd4f01370
commit 9df4fcbbb6
6 changed files with 256 additions and 71 deletions

View File

@ -14,15 +14,13 @@ test('Basic (callback)', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
client.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
}, (err, { body }) => {
t.error(err)
t.deepEqual(body, { hello: 'world' })
@ -40,16 +38,14 @@ test('Basic (promises)', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
client
.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
})
.then(({ body }) => t.deepEqual(body, { hello: 'world' }))
.catch(t.fail)
@ -67,15 +63,13 @@ test('Error (callback)', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
client.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
}, (err, { body }) => {
t.ok(err)
})
@ -93,16 +87,14 @@ test('Error (promises)', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
client
.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
})
.then(t.fail)
.catch(err => t.ok(err))
@ -119,15 +111,13 @@ test('Abort method (callback)', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
const request = client.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
}, (err, { body }) => {
t.error(err)
t.deepEqual(body, { hello: 'world' })
@ -147,15 +137,13 @@ test('Abort is not supported in promises', t => {
buildServer(handler, ({ port }, server) => {
const client = new Client({
host: `http://localhost:${port}`
node: `http://localhost:${port}`
})
const request = client.search({
index: 'test',
type: 'doc',
query: {
match: { foo: 'bar' }
}
q: 'foo:bar'
})
request