Updated test

This commit is contained in:
delvedor
2020-09-07 10:00:52 +02:00
parent 471d0a5563
commit 8a87e454a4
4 changed files with 201 additions and 42 deletions

View File

@ -4,35 +4,26 @@ import { test } from 'tap'
/* eslint-disable no-unused-vars */
import * as types from '../../dsl/lib/types'
/* eslint-enable no-unused-vars */
import { F } from '../../dsl'
import { F, Q } from '../../dsl'
test('match', t => {
t.deepEqual(F()
.match('foo', 'bar')
.match('foo', 'baz')
.build(), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ match: { foo: 'baz' } }
]
}
}
})
.build(),
Q(
Q.match('foo', 'bar'),
Q.match('foo', 'baz')
)
)
t.deepEqual(F()
.match('foo', ['bar', 'baz'])
.build(), {
query: {
bool: {
must: [
{ match: { foo: 'bar' } },
{ match: { foo: 'baz' } }
]
}
}
})
.build(),
Q(
Q.match('foo', ['bar', 'baz'])
)
)
t.end()
})
@ -40,11 +31,9 @@ test('match', t => {
test('matchPhrase', t => {
t.deepEqual(F()
.matchPhrase('foo', 'bar')
.build(), {
query: {
match_phrase: { foo: 'bar' },
}
})
.build(),
Q(Q.matchPhrase('foo', 'bar'))
)
t.end()
})
@ -52,11 +41,45 @@ test('matchPhrase', t => {
test('matchPhrasePrefix', t => {
t.deepEqual(F()
.matchPhrasePrefix('foo', 'bar')
.build(), {
query: {
match_phrase_prefix: { foo: 'bar' },
}
})
.build(),
Q(Q.matchPhrasePrefix('foo', 'bar'))
)
t.end()
})
test('multiMatch', t => {
t.deepEqual(F()
.multiMatch(['foo1', 'foo2'], 'bar')
.build(),
Q(Q.multiMatch(['foo1', 'foo2'], 'bar'))
)
t.end()
})
test('matchAll', t => {
t.deepEqual(F()
.matchAll()
.build(),
Q(Q.matchAll())
)
t.deepEqual(F()
.matchAll({ boost: 1 })
.build(),
Q(Q.matchAll({ boost: 1 }))
)
t.end()
})
test('matchNone', t => {
t.deepEqual(F()
.matchNone()
.build(),
Q(Q.matchNone())
)
t.end()
})