Files
gitlab-foss/spec/frontend/packages_and_registries/dependency_proxy/utils_spec.js
2023-08-28 12:10:42 +00:00

26 lines
782 B
JavaScript

import { getPageParams } from '~/packages_and_registries/dependency_proxy/utils';
describe('getPageParams', () => {
it('should return the previous page params if before cursor is available', () => {
const pageInfo = { before: 'abc123' };
expect(getPageParams(pageInfo)).toEqual({
first: null,
before: pageInfo.before,
last: 20,
});
});
it('should return the next page params if after cursor is available', () => {
const pageInfo = { after: 'abc123' };
expect(getPageParams(pageInfo)).toEqual({
after: pageInfo.after,
first: 20,
});
});
it('should return an empty object if both before and after cursors are not available', () => {
const pageInfo = {};
expect(getPageParams(pageInfo)).toEqual({});
});
});