Skip to content

Commit

Permalink
add test for has_parent backwards compatability with filter
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-scharlach committed Aug 16, 2017
1 parent 8a0d7c0 commit 55d6aef
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/query-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,40 @@ test('queryBuilder | hasParent (valid v2 syntax)', (t) => {
})
})

test('queryBuilder | has_parent filter v1 syntax', (t) => {
t.plan(1)

const result = queryBuilder().query('hasParent', 'parentTag', 'blog', (q) => {
return q.filter('term', 'tag', 'something')
})

t.deepEqual(result.getQuery('v1'), {
hasParent: {
parentTag: 'blog',
filter: {
term: { tag: 'something' }
}
}
})
})

test('queryBuilder | has_parent filter v1 syntax', (t) => {
t.plan(1)

const result = queryBuilder().query('hasParent', 'parentTag', 'blog', (q) => {
return q.filter('term', 'tag', 'something')
})

t.deepEqual(result.getQuery(), {
hasParent: {
parentTag: 'blog',
query: { bool: {filter: {
term: { tag: 'something' }
} } }
}
})
})

test('queryBuilder | geo_bounding_box', (t) => {
t.plan(1)

Expand Down

0 comments on commit 55d6aef

Please sign in to comment.