Fix pagination totals for zero counts
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-23 17:33:18 +01:00
parent 7dd8bc4c91
commit db90b9af2e
2 changed files with 21 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { normalizeTenantPackage } from '../api';
import { buildPagination, normalizeTenantPackage } from '../api';
describe('normalizeTenantPackage', () => {
it('keeps remaining_events null when payload is null', () => {
@@ -17,3 +17,15 @@ describe('normalizeTenantPackage', () => {
expect(normalized.remaining_events).toBe(2);
});
});
describe('buildPagination', () => {
it('keeps totals at zero when meta total is zero', () => {
const meta = buildPagination({ meta: { total: 0, per_page: 1, current_page: 1, last_page: 1 } } as any, 1);
expect(meta.total).toBe(0);
});
it('falls back to data length when total is missing', () => {
const meta = buildPagination({ data: [] } as any, 1);
expect(meta.total).toBe(0);
});
});