fix: parameter shadowing and pagination test coverage

- Rename setContributors parameter to avoid shadowing 'contributors' variable
- Add test coverage for getNextPage and resetPagination utilities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
StillKnotKnown
2026-03-13 14:32:55 +02:00
parent db5eff4b9b
commit 4e2a614112
2 changed files with 15 additions and 3 deletions
@@ -204,8 +204,8 @@ export function useGitLabMRFiltering(
setFiltersState(prev => ({ ...prev, searchQuery: query }));
}, []);
const setContributors = useCallback((contributors: string[]) => {
setFiltersState(prev => ({ ...prev, contributors }));
const setContributors = useCallback((selected: string[]) => {
setFiltersState(prev => ({ ...prev, contributors: selected }));
}, []);
const setStatuses = useCallback((statuses: GitLabMRStatusFilter[]) => {
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
import { calculateHasMore, appendWithoutDuplicates } from '../pagination-utils';
import { calculateHasMore, appendWithoutDuplicates, getNextPage, resetPagination } from '../pagination-utils';
describe('pagination-utils', () => {
it('should calculate hasMore correctly', () => {
@@ -27,4 +27,16 @@ describe('pagination-utils', () => {
const result = appendWithoutDuplicates(existing, newItems, 'id');
expect(result).toHaveLength(2);
});
it('should get next page', () => {
expect(getNextPage(1)).toBe(2);
expect(getNextPage(5)).toBe(6);
expect(getNextPage(0)).toBe(1);
});
it('should reset pagination', () => {
const result = resetPagination();
expect(result.currentPage).toBe(1);
expect(result.hasMore).toBe(true);
});
});