diff --git a/__test__/unittest/query_builder.test.ts b/__test__/unittest/query_builder.test.ts index a26f4b3..bd05b44 100644 --- a/__test__/unittest/query_builder.test.ts +++ b/__test__/unittest/query_builder.test.ts @@ -299,7 +299,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after APIEdge split from query_graph_handler const builder = new qb(edge); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with post method should return false", () => { @@ -316,7 +319,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after APIEdge split from query_graph_handler const builder = new qb(edge); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with get method and needs pagniation should return true", () => { @@ -333,7 +339,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after APIEdge split from query_graph_handler const builder = new qb(edge); const res = builder.needPagination(response); - expect(res).toBeTruthy(); + expect(res).not.toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with get method and doesn't need pagniation should return false", () => { @@ -350,7 +359,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after APIEdge split from query_graph_handler const builder = new qb(edge); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); }); }); diff --git a/__test__/unittest/template_query_builder.test.ts b/__test__/unittest/template_query_builder.test.ts index 9b0dc9c..e372905 100644 --- a/__test__/unittest/template_query_builder.test.ts +++ b/__test__/unittest/template_query_builder.test.ts @@ -366,7 +366,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after extracting APIEdge from query_graph_handler const builder = new qb(edge, queryHandlerOptions); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with post method should return false", () => { @@ -385,7 +388,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after extracting APIEdge from query_graph_handler const builder = new qb(edge, queryHandlerOptions); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with get method and needs pagniation should return true", () => { @@ -403,7 +409,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after extracting APIEdge from query_graph_handler const builder = new qb(edge, queryHandlerOptions); const res = builder.needPagination(response); - expect(res).toBeTruthy(); + expect(res).not.toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); test("biothings tagged api with get method and doesn't need pagniation should return false", () => { @@ -421,7 +430,10 @@ describe("test query builder class", () => { // @ts-expect-error TODO: change after extracting APIEdge from query_graph_handler const builder = new qb(edge, queryHandlerOptions); const res = builder.needPagination(response); - expect(res).toBeFalsy(); + expect(res).toMatchObject({ + paginationStart: 0, + paginationSize: 0 + }); }); }); }); diff --git a/src/builder/template_query_builder.ts b/src/builder/template_query_builder.ts index 12707ba..ae58d02 100644 --- a/src/builder/template_query_builder.ts +++ b/src/builder/template_query_builder.ts @@ -168,6 +168,7 @@ export default class TemplateQueryBuilder extends BaseQueryBuilder { } } else if ( this.APIEdge.query_operation.method === "get" && + this.APIEdge.association != null && // abstract comparison for null and undefined this.APIEdge.association.api_name === "Monarch API" ) { if (