chore(journey): keep the map stop and connection types to their files

ConnectionStop, EntryConnections and JourneyMapStop are only used in the
signatures of their own modules, and knip counts an export nothing
imports. The connection tests take the FE- prefix and header the other
journey tests carry.
This commit is contained in:
Maurice
2026-10-29 17:26:21 +01:00
parent c71ecc8f76
commit c0e951fc8e
3 changed files with 12 additions and 11 deletions
@@ -1,3 +1,4 @@
// FE-JRN-CONN-001 to FE-JRN-CONN-008
import type { JourneyTrack } from '@trek/shared';
import { describe, expect, it } from 'vitest';
import { coveredConnectionsShown, entryConnections } from './journeyMapConnections';
@@ -16,7 +17,7 @@ function recorded(
}
describe('entryConnections (#2888)', () => {
it('JMCONN-001: without a recording the whole line stays open, one polyline through every stop', () => {
it('FE-JRN-CONN-001: without a recording the whole line stays open, one polyline through every stop', () => {
const result = entryConnections([stop(1, '2026-10-29'), stop(2, '2026-10-29'), stop(3, '2026-10-30')], []);
expect(result.open).toEqual([
[
@@ -28,7 +29,7 @@ describe('entryConnections (#2888)', () => {
expect(result.covered).toEqual([]);
});
it('JMCONN-002: a recorded day covers the stretches between its entries, the jump into a day without one stays open', () => {
it('FE-JRN-CONN-002: a recorded day covers the stretches between its entries, the jump into a day without one stays open', () => {
const result = entryConnections(
[stop(1, '2026-10-29'), stop(2, '2026-10-29'), stop(3, '2026-10-30'), stop(4, '2026-10-30')],
[recorded('2026-10-29', 'dawarich_live')]
@@ -48,13 +49,13 @@ describe('entryConnections (#2888)', () => {
]);
});
it('JMCONN-003: the night between two recorded days is covered, a day in between without one is not', () => {
it('FE-JRN-CONN-003: the night between two recorded days is covered, a day in between without one is not', () => {
const tracks = [recorded('2026-10-29'), recorded('2026-10-30'), recorded('2026-11-01')];
expect(entryConnections([stop(1, '2026-10-29'), stop(2, '2026-10-30')], tracks).open).toEqual([]);
expect(entryConnections([stop(1, '2026-10-30'), stop(2, '2026-11-01')], tracks).covered).toEqual([]);
});
it('JMCONN-004: a trip GPX, a line without a day and a recording without points cover nothing', () => {
it('FE-JRN-CONN-004: a trip GPX, a line without a day and a recording without points cover nothing', () => {
const stops = [stop(1, '2026-10-29'), stop(2, '2026-10-29')];
const gpx: JourneyTrack = { ...recorded('2026-10-29'), kind: 'trip_gpx' };
const undated: JourneyTrack = { ...recorded('2026-10-29'), date: undefined };
@@ -62,7 +63,7 @@ describe('entryConnections (#2888)', () => {
expect(entryConnections(stops, [gpx, undated, empty]).covered).toEqual([]);
});
it('JMCONN-005: open and covered stretches alternate in the order of the stops', () => {
it('FE-JRN-CONN-005: open and covered stretches alternate in the order of the stops', () => {
const result = entryConnections(
[
stop(1, '2026-10-28'),
@@ -95,20 +96,20 @@ describe('entryConnections (#2888)', () => {
]);
});
it('JMCONN-006: a timestamp is read by its day, and an unreadable date never counts as recorded', () => {
it('FE-JRN-CONN-006: a timestamp is read by its day, and an unreadable date never counts as recorded', () => {
expect(
entryConnections([stop(1, '2026-10-29T08:00:00Z'), stop(2, '2026-10-29')], [recorded('2026-10-29')]).open
).toEqual([]);
expect(entryConnections([stop(1, 'someday'), stop(2, '2026-10-29')], [recorded('2026-10-29')]).covered).toEqual([]);
});
it('JMCONN-007: fewer than two stops make no line', () => {
it('FE-JRN-CONN-007: fewer than two stops make no line', () => {
expect(entryConnections([stop(1, '2026-10-29')], [])).toEqual({ open: [], covered: [] });
});
});
describe('coveredConnectionsShown', () => {
it('JMCONN-008: stands in only while the entries show and the recording is hidden', () => {
it('FE-JRN-CONN-008: stands in only while the entries show and the recording is hidden', () => {
expect(coveredConnectionsShown({ plan: true, recorded: true, entries: true })).toBe(false);
expect(coveredConnectionsShown({ plan: true, recorded: false, entries: true })).toBe(true);
expect(coveredConnectionsShown({ plan: true, recorded: false, entries: false })).toBe(false);
@@ -5,7 +5,7 @@ import { isPlannedTrack, type JourneyMapLayerVisibility } from './journeyMapLaye
type LatLng = [number, number];
/** An entry pin as the connection sees it: where it stands and on which day. */
export interface ConnectionStop {
interface ConnectionStop {
lat: number;
lng: number;
/** `YYYY-MM-DD`; a longer ISO string is read by its date. */
@@ -22,7 +22,7 @@ export interface ConnectionStop {
* one across it only gets in its way (#2888). It is still handed back, so a
* reader who hides what was recorded gets the guess back for those stretches.
*/
export interface EntryConnections {
interface EntryConnections {
open: LatLng[][];
covered: LatLng[][];
}
@@ -19,7 +19,7 @@ export interface JourneyStopEntry {
location_lng?: number | null;
}
export interface JourneyMapStop<E> {
interface JourneyMapStop<E> {
entry: E;
/** The stop's place in the whole journey, or null for a draft the share link does not show. */
stop: number | null;