Skip to content

Commit 49ef3b0

Browse files
committed
Add tests for new hybrid groupby feature
1 parent 144fcc4 commit 49ef3b0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/graphql/getter.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,21 @@ describe('hybrid valid searchers', () => {
13831383

13841384
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
13851385
});
1386+
1387+
test('query and groupby', () => {
1388+
const expectedQuery = `{Get{Person(hybrid:{query:"accountant"},groupBy:{path:["employer"],groups:2,objectsPerGroup:3}){name}}}`;
1389+
1390+
new Getter(mockClient)
1391+
.withClassName('Person')
1392+
.withFields('name')
1393+
.withHybrid({
1394+
query: 'accountant',
1395+
})
1396+
.withGroupBy({ path: ['employer'], groups: 2, objectsPerGroup: 3 })
1397+
.do();
1398+
1399+
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
1400+
});
13861401
});
13871402

13881403
describe('generative search', () => {

src/graphql/journey.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,26 @@ describe('the graphql journey', () => {
424424
});
425425
});
426426

427+
test('graphql get hybrid with query and groupby', () => {
428+
return client.graphql
429+
.get()
430+
.withClassName('Article')
431+
.withHybrid({ query: 'Apple', properties: ['title'], alpha: 0 })
432+
.withGroupBy({
433+
path: ['title'],
434+
objectsPerGroup: 1,
435+
groups: 1,
436+
})
437+
.withFields('_additional { id }')
438+
.do()
439+
.then((res: any) => {
440+
expect(res.data.Get.Article.length).toBe(1);
441+
})
442+
.catch((e: any) => {
443+
throw new Error('it should not have errord' + e);
444+
});
445+
});
446+
427447
test('graphql get with nearText (with certainty)', () => {
428448
return client.graphql
429449
.get()

0 commit comments

Comments
 (0)