11import expect from 'expect.js' ;
22import * as is from '../is' ;
33import { nodeTypes } from '../../node_types' ;
4- import _ from 'lodash' ;
54import StubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern' ;
65import ngMock from 'ng_mock' ;
6+ import { expectDeepEqual } from '../../../../../test_utils/expect_deep_equal' ;
77
88let indexPattern ;
99
@@ -54,34 +54,22 @@ describe('kuery functions', function () {
5454
5555 const node = nodeTypes . function . buildNode ( 'is' , '*' , '*' ) ;
5656 const result = is . toElasticsearchQuery ( node , indexPattern ) ;
57- expect ( _ . isEqual ( expected , result ) ) . to . be ( true ) ;
57+ expectDeepEqual ( result , expected ) ;
5858 } ) ;
5959
60- it ( 'should return an ES simple_query_string query in all fields mode when fieldName is "*"' , function ( ) {
60+ it ( 'should return an ES multi_match query when fieldName is "*"' , function ( ) {
6161 const expected = {
62- simple_query_string : {
63- query : '"200"' ,
64- all_fields : true ,
62+ multi_match : {
63+ query : 200 ,
64+ fields : [ '*' ] ,
65+ type : 'phrase' ,
66+ lenient : true ,
6567 }
6668 } ;
6769
6870 const node = nodeTypes . function . buildNode ( 'is' , '*' , 200 ) ;
6971 const result = is . toElasticsearchQuery ( node , indexPattern ) ;
70- expect ( _ . isEqual ( expected , result ) ) . to . be ( true ) ;
71- } ) ;
72-
73- // See discussion about kuery escaping for background:
74- // https://github.com/elastic/kibana/pull/12624#issuecomment-312650307
75- it ( 'should ensure the simple_query_string query is wrapped in double quotes to force a phrase search' , function ( ) {
76- const node = nodeTypes . function . buildNode ( 'is' , '*' , '+response' ) ;
77- const result = is . toElasticsearchQuery ( node , indexPattern ) ;
78- expect ( result . simple_query_string . query ) . to . be ( '"+response"' ) ;
79- } ) ;
80-
81- it ( 'already double quoted phrases should not get wrapped a second time' , function ( ) {
82- const node = nodeTypes . function . buildNode ( 'is' , '*' , '"+response"' ) ;
83- const result = is . toElasticsearchQuery ( node , indexPattern ) ;
84- expect ( result . simple_query_string . query ) . to . be ( '"+response"' ) ;
72+ expectDeepEqual ( result , expected ) ;
8573 } ) ;
8674
8775 it ( 'should return an ES exists query when value is "*"' , function ( ) {
@@ -91,7 +79,7 @@ describe('kuery functions', function () {
9179
9280 const node = nodeTypes . function . buildNode ( 'is' , 'response' , '*' ) ;
9381 const result = is . toElasticsearchQuery ( node , indexPattern ) ;
94- expect ( _ . isEqual ( expected , result ) ) . to . be ( true ) ;
82+ expectDeepEqual ( result , expected ) ;
9583 } ) ;
9684
9785 it ( 'should return an ES match_phrase query when a concrete fieldName and value are provided' , function ( ) {
@@ -103,7 +91,7 @@ describe('kuery functions', function () {
10391
10492 const node = nodeTypes . function . buildNode ( 'is' , 'response' , 200 ) ;
10593 const result = is . toElasticsearchQuery ( node , indexPattern ) ;
106- expect ( _ . isEqual ( expected , result ) ) . to . be ( true ) ;
94+ expectDeepEqual ( result , expected ) ;
10795 } ) ;
10896
10997 it ( 'should support scripted fields' , function ( ) {
0 commit comments