File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1602,7 +1602,7 @@ class ParseQuery<T extends ParseObject = ParseObject> {
16021602 * of the search
16031603 * */
16041604
1605- async search ( value : string , path : string [ ] , options : SearchOptions = { } ) : Promise < Array < any > > {
1605+ async search ( value : string , path : string [ ] , options : SearchOptions = { } ) : Promise < T [ ] > {
16061606 if ( ! value ) {
16071607 throw new Error ( 'A search term is required.' ) ;
16081608 }
Original file line number Diff line number Diff line change @@ -2743,6 +2743,19 @@ describe('ParseQuery', () => {
27432743 await expect ( q . search ( 123 ) ) . rejects . toThrow ( 'The value being searched for must be a string.' ) ;
27442744 } ) ;
27452745
2746+ it ( 'search can return an empty array if no results' , async ( ) => {
2747+ CoreManager . setQueryController ( {
2748+ find ( ) { } ,
2749+ aggregate ( ) {
2750+ return Promise . resolve ( { } ) ;
2751+ } ,
2752+ } ) ;
2753+
2754+ const q = new ParseQuery ( 'Item' ) ;
2755+ const results = await q . search ( 'searchTerm' , [ 'name' ] , { index : 'searchIndex' } ) ;
2756+ expect ( results ) . toEqual ( [ ] ) ;
2757+ } ) ;
2758+
27462759 it ( 'aggregate query array pipeline with equalTo' , done => {
27472760 const pipeline = [ { group : { objectId : '$name' } } ] ;
27482761 MockRESTController . request . mockImplementationOnce ( ( ) => {
You can’t perform that action at this time.
0 commit comments