Files
TREK/client/src/components/shared/categoryIcons.test.ts
T
Maurice 66d85729ff feat(categories): icons for parking, bus stops, stations, airports and fuel (#2706)
The category picker had no icon to tell a car park or a terminal apart from the
places a trip visits. Five transport icons join the shared table, which the admin
pickers, map pins and the PDF all read; the ship's tooltip now also says ferry.
2026-11-13 10:17:04 +01:00

30 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { CATEGORY_ICON_MAP, ICON_LABELS, getCategoryIcon } from './categoryIcons';
import { BusFront, Fuel, MapPin, ParkingSquare, PlaneTakeoff, TrainFront } from 'lucide-react';
describe('categoryIcons', () => {
it('FE-COMP-CATICONS-001: every icon the category picker offers has a label for its tooltip', () => {
expect(Object.keys(CATEGORY_ICON_MAP).filter((name) => !ICON_LABELS[name])).toEqual([]);
expect(Object.keys(ICON_LABELS).filter((name) => !CATEGORY_ICON_MAP[name])).toEqual([]);
});
it('FE-COMP-CATICONS-002: parking, stops, stations, airports and fuel have icons of their own (#2706)', () => {
expect(getCategoryIcon('ParkingSquare')).toBe(ParkingSquare);
expect(getCategoryIcon('BusFront')).toBe(BusFront);
expect(getCategoryIcon('TrainFront')).toBe(TrainFront);
expect(getCategoryIcon('PlaneTakeoff')).toBe(PlaneTakeoff);
expect(getCategoryIcon('Fuel')).toBe(Fuel);
expect(ICON_LABELS.ParkingSquare).toBe('Parking');
expect(ICON_LABELS.PlaneTakeoff).toBe('Airport');
expect(ICON_LABELS.Ship).toBe('Ship / Ferry');
});
it('FE-COMP-CATICONS-003: an unknown or missing icon name falls back to the pin', () => {
expect(getCategoryIcon('NoSuchIcon')).toBe(MapPin);
expect(getCategoryIcon(null)).toBe(MapPin);
expect(getCategoryIcon(undefined)).toBe(MapPin);
});
});