@@ -1430,3 +1430,114 @@ describe('groupBy valid searchers', () => {
14301430 expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
14311431 } ) ;
14321432} ) ;
1433+
1434+ describe ( 'query with where with ContainsAny / ContainsAll operators' , ( ) => {
1435+ const mockClient : any = {
1436+ query : jest . fn ( ) ,
1437+ } ;
1438+
1439+ const operators : Array < WhereFilter [ 'operator' ] > = [ 'ContainsAll' , 'ContainsAny' ] ;
1440+
1441+ test . each ( operators ) ( 'valueTextArray with %s' , ( operator ) => {
1442+ const whereQuery = `(where:{operator:` + operator + `,valueText:["red","blue","green"],path:["colors"]})` ;
1443+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{colors}}}` ;
1444+
1445+ new Getter ( mockClient )
1446+ . withClassName ( 'WhereTest' )
1447+ . withFields ( 'colors' )
1448+ . withWhere ( {
1449+ operator,
1450+ path : [ 'colors' ] ,
1451+ valueTextArray : [ 'red' , 'blue' , 'green' ] ,
1452+ } )
1453+ . do ( ) ;
1454+
1455+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1456+ } ) ;
1457+
1458+ test . each ( operators ) ( 'valueStringArray with %s' , ( operator ) => {
1459+ const whereQuery = `(where:{operator:` + operator + `,valueString:["red"],path:["colors"]})` ;
1460+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{colors}}}` ;
1461+
1462+ new Getter ( mockClient )
1463+ . withClassName ( 'WhereTest' )
1464+ . withFields ( 'colors' )
1465+ . withWhere ( {
1466+ operator,
1467+ path : [ 'colors' ] ,
1468+ valueStringArray : [ 'red' ] ,
1469+ } )
1470+ . do ( ) ;
1471+
1472+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1473+ } ) ;
1474+
1475+ test . each ( operators ) ( 'valueNumberArray with %s' , ( operator ) => {
1476+ const whereQuery = `(where:{operator:` + operator + `,valueNumber:[1.1,2.1],path:["numbers"]})` ;
1477+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{numbers}}}` ;
1478+
1479+ new Getter ( mockClient )
1480+ . withClassName ( 'WhereTest' )
1481+ . withFields ( 'numbers' )
1482+ . withWhere ( {
1483+ operator,
1484+ path : [ 'numbers' ] ,
1485+ valueNumberArray : [ 1.1 , 2.1 ] ,
1486+ } )
1487+ . do ( ) ;
1488+
1489+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1490+ } ) ;
1491+
1492+ test . each ( operators ) ( 'valueIntArray with %s' , ( operator ) => {
1493+ const whereQuery = `(where:{operator:` + operator + `,valueInt:[1],path:["numbers"]})` ;
1494+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{numbers}}}` ;
1495+
1496+ new Getter ( mockClient )
1497+ . withClassName ( 'WhereTest' )
1498+ . withFields ( 'numbers' )
1499+ . withWhere ( {
1500+ operator,
1501+ path : [ 'numbers' ] ,
1502+ valueIntArray : [ 1 ] ,
1503+ } )
1504+ . do ( ) ;
1505+
1506+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1507+ } ) ;
1508+
1509+ test . each ( operators ) ( 'valueDateArray with %s' , ( operator ) => {
1510+ const whereQuery =
1511+ `(where:{operator:` + operator + `,valueDate:["2009-11-01T23:00:00Z"],path:["dates"]})` ;
1512+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{dates}}}` ;
1513+
1514+ new Getter ( mockClient )
1515+ . withClassName ( 'WhereTest' )
1516+ . withFields ( 'dates' )
1517+ . withWhere ( {
1518+ operator,
1519+ path : [ 'dates' ] ,
1520+ valueDateArray : [ '2009-11-01T23:00:00Z' ] ,
1521+ } )
1522+ . do ( ) ;
1523+
1524+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1525+ } ) ;
1526+
1527+ test . each ( operators ) ( 'valueBooleanArray with %s' , ( operator ) => {
1528+ const whereQuery = `(where:{operator:` + operator + `,valueBoolean:[true,false],path:["bools"]})` ;
1529+ const expectedQuery = `{Get{WhereTest` + whereQuery + `{bools}}}` ;
1530+
1531+ new Getter ( mockClient )
1532+ . withClassName ( 'WhereTest' )
1533+ . withFields ( 'bools' )
1534+ . withWhere ( {
1535+ operator,
1536+ path : [ 'bools' ] ,
1537+ valueBooleanArray : [ true , false ] ,
1538+ } )
1539+ . do ( ) ;
1540+
1541+ expect ( mockClient . query ) . toHaveBeenCalledWith ( expectedQuery ) ;
1542+ } ) ;
1543+ } ) ;
0 commit comments