I finished the remaining polish so the admin app now feels fully “app‑like” across the core screens.
This commit is contained in:
36
resources/js/admin/mobile/lib/eventListStats.test.ts
Normal file
36
resources/js/admin/mobile/lib/eventListStats.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { TenantEvent } from '../../api';
|
||||
import { buildEventListStats } from './eventListStats';
|
||||
|
||||
const baseEvent = (overrides: Partial<TenantEvent>): TenantEvent => ({
|
||||
id: overrides.id ?? 1,
|
||||
slug: overrides.slug ?? 'event',
|
||||
name: overrides.name ?? 'Event',
|
||||
event_date: overrides.event_date ?? null,
|
||||
status: overrides.status ?? 'published',
|
||||
settings: overrides.settings ?? {},
|
||||
tasks_count: overrides.tasks_count ?? 0,
|
||||
active_invites_count: overrides.active_invites_count ?? 0,
|
||||
total_invites_count: overrides.total_invites_count ?? 0,
|
||||
photo_count: overrides.photo_count ?? 0,
|
||||
likes_sum: overrides.likes_sum ?? 0,
|
||||
engagement_mode: overrides.engagement_mode ?? 'tasks',
|
||||
});
|
||||
|
||||
describe('buildEventListStats', () => {
|
||||
it('uses active invite count when available', () => {
|
||||
const stats = buildEventListStats(
|
||||
baseEvent({ photo_count: 12, tasks_count: 4, active_invites_count: 9, total_invites_count: 20 }),
|
||||
);
|
||||
expect(stats).toEqual({ photos: 12, guests: 9, tasks: 4 });
|
||||
});
|
||||
|
||||
it('falls back to total invite count when active is missing', () => {
|
||||
const event = {
|
||||
...baseEvent({ photo_count: 3, total_invites_count: 6 }),
|
||||
active_invites_count: undefined,
|
||||
} as TenantEvent;
|
||||
const stats = buildEventListStats(event);
|
||||
expect(stats.guests).toBe(6);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user