All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
generator.client.pagination.secondary.RestPage.spec.ts.mustache Maven / Gradle / Ivy
import { describe, expect, it } from 'vitest';
import { RestPage, toPage } from '@/shared/pagination/infrastructure/secondary/RestPage';
import { Page } from '@/shared/pagination/domain/Page';
describe('RestPage', () => {
it('should map empty page', () => {
expect(
toPage(mapValue)({
data: emptyRestPage(),
}),
).toEqual(emptyPage());
});
it('should map to page', () => {
expect(toPage(mapValue)({ data: restPage() })).toEqual(page());
});
});
const mapValue = (value: string): string => value + value;
const emptyRestPage = () => ({
currentPage: 0,
pagesCount: 0,
pageSize: 1,
hasPrevious: false,
hasNext: false,
totalElementsCount: 0,
content: [],
});
const emptyPage = () => ({
currentPage: 1,
pagesCount: 0,
hasPrevious: false,
hasNext: false,
totalElementsCount: 0,
displayed: { start: 0, end: 0 },
content: [],
});
const restPage = (): RestPage => ({
currentPage: 1,
pagesCount: 5,
pageSize: 1,
hasPrevious: true,
hasNext: true,
totalElementsCount: 5,
content: ['test'],
});
const page = (): Page => ({
currentPage: 2,
pagesCount: 5,
hasPrevious: true,
hasNext: true,
totalElementsCount: 5,
displayed: {
start: 2,
end: 2,
},
content: ['testtest'],
});