🐛Fixed pagination for PostgreSQL connector

This commit is contained in:
Anton SHEPILOV
2024-07-12 00:22:33 +02:00
committed by Anton Shepilov
parent 845781642f
commit 585da88b0d
4 changed files with 34 additions and 6 deletions
@@ -44,7 +44,7 @@ describe("the Drive feature", () => {
currentUser = await UserApi.getInstance(platform);
});
afterAll(async () => {
afterEach(async () => {
await platform?.tearDown();
platform = null;
});
@@ -7,6 +7,7 @@ import {
} from "../../../../../../../../../src/core/platform/services/database/services/orm/connectors/postgres/postgres";
import { getEntityDefinition } from '../../../../../../../../../src/core/platform/services/database/services/orm/utils';
import { TestDbEntity, normalizeWhitespace, newTestDbEntity } from "./utils";
import { Pagination } from "../../../../../../../../../src/core/platform/framework/api/crud-service";
describe('The Postgres Connector module', () => {
@@ -28,6 +29,28 @@ describe('The Postgres Connector module', () => {
jest.clearAllMocks();
});
test('nextPage successfully iterate starting from null value', () => {
//given
const pagination = new Pagination(null, "5");
//when
let nextPage = subj.nextPage(pagination, 5);
//then
expect(nextPage.page_token).toEqual("1")
expect(nextPage.limitStr).toEqual("5");
nextPage = subj.nextPage(Pagination.fromPaginable(nextPage), 5);
//then
expect(nextPage.page_token).toEqual("2")
expect(nextPage.limitStr).toEqual("5");
nextPage = subj.nextPage(Pagination.fromPaginable(nextPage), 1);
//then
expect(nextPage.page_token).toEqual(false)
expect(nextPage.limitStr).toEqual("5");
})
test('createTable generates table structure queries', async () => {
// given
const definition = getEntityDefinition(new TestDbEntity());