mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 00:20:07 +00:00
10713e41cd
Client lint, checks and tests were red on the globe Atlas: - The views own the globe and sky refs and hand them into useAtlasGlobe, so reading its state while rendering no longer counts as reading refs. - Helpers that shared a file with components move to their own modules (badge tiers, medal label, Dawarich notes, hub tabs, period label). - The place search derives its loading state, the search resets its active row on input, and the two silenced hook dependencies are named. - placeLabels, the hover chip and the overview figures are split up. - Raw text sizes become type tiers, the badge unlock docks on --z-overlay. - The stats card test follows the GlobeStat props; baselines lowered to the counts the run reported.
41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { Award, Flag, Globe, MapIcon, Plane, Star } from 'lucide-react';
|
|
import { fireEvent, render, screen } from '../../../helpers/render';
|
|
import MAtlasStatsCard from '../../../../src/mobile/screens/atlas/MAtlasStatsCard';
|
|
import type { GlobeStat } from '../../../../src/components/AtlasGlobe/GlobeStatsBar';
|
|
|
|
// FE-MOB-ATLAS-010 to FE-MOB-ATLAS-012
|
|
|
|
const stat = (key: string, value: number | string, label: string, icon = Flag): GlobeStat => ({ key, value, label, icon, onClick: vi.fn() });
|
|
|
|
const stats: GlobeStat[] = [
|
|
stat('countries', 37, 'Countries'),
|
|
stat('continents', 6, 'Continents', Globe),
|
|
stat('regions', 42, 'Regions', MapIcon),
|
|
stat('flights', '152k', 'Flight km', Plane),
|
|
stat('badges', 22, 'Badges', Award),
|
|
stat('wishlist', 4, 'Wishlist', Star),
|
|
];
|
|
|
|
describe('MAtlasStatsCard', () => {
|
|
it('FE-MOB-ATLAS-010: shows the five phone figures in their order', () => {
|
|
render(<MAtlasStatsCard stats={stats} />);
|
|
|
|
const labels = screen.getAllByRole('button').map((b) => b.textContent);
|
|
expect(labels).toEqual(['37Countries', '6Continents', '42Regions', '22Badges', '4Wishlist']);
|
|
});
|
|
|
|
it('FE-MOB-ATLAS-011: leaves out the figures the phone card has no room for', () => {
|
|
render(<MAtlasStatsCard stats={stats} />);
|
|
|
|
expect(screen.queryByText('Flight km')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-ATLAS-012: a column opens what it counts', () => {
|
|
render(<MAtlasStatsCard stats={stats} />);
|
|
|
|
fireEvent.click(screen.getByText('Badges'));
|
|
expect(stats[4]?.onClick).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|