- Introduced `PassengerInfo.tsx` for displaying trip details, including upcoming trips and fare information. - Added `PassengerSettings.tsx` for managing user-defined important places and fare settings. - Implemented validation functions for passenger settings in `passenger-settings.mjs`. - Created utility functions for transliterating stop names in `transliteration.ts`. - Developed weather hint functionality in `weather-hint.ts` to provide precipitation probabilities. - Established a mock server for testing passenger-related features in `passenger-server.mjs`. - Added comprehensive tests for passenger guide logic and transliteration functionality.
26 lines
1.8 KiB
JavaScript
26 lines
1.8 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { boardScenes, informationBlocks } from '../src/lib/information.ts';
|
|
import { defaultSettings } from '../src/lib/storage.ts';
|
|
|
|
const off = { ...defaultSettings, infoServiceEnabled: false, infoWeatherEnabled: false, infoQrEnabled: false, infoPlacesEnabled: false, infoFareEnabled: false };
|
|
|
|
test('disabled information blocks are omitted without leaving gaps in the cycle', () => {
|
|
assert.deepEqual(informationBlocks(defaultSettings).map(block => block.id), ['service', 'weather', 'qr', 'fare']);
|
|
assert.deepEqual(informationBlocks({ ...off, infoQrEnabled: true }).map(block => block.id), ['qr']);
|
|
assert.deepEqual(informationBlocks({ ...defaultSettings, infoWeatherEnabled: false }).map(block => block.id), ['service', 'qr', 'fare']);
|
|
assert.deepEqual(informationBlocks(off), []);
|
|
});
|
|
test('unconfigured or unavailable passenger cards do not leave empty scenes', () => {
|
|
assert.deepEqual(informationBlocks(defaultSettings, { places: false, fare: false }).map(b => b.id), ['service', 'weather', 'qr']);
|
|
assert.deepEqual(boardScenes({ ...off, infoFareEnabled: true }, false, false, { places: false, fare: false }), ['departures']);
|
|
const configured = { ...defaultSettings, places: [{ stopId: 2, name: 'Вокзал' }] };
|
|
assert.equal(informationBlocks(configured, { places: true, fare: true }).length, 5);
|
|
});
|
|
test('all blocks off keeps departures, retains optional advertising, and still surfaces alerts', () => {
|
|
assert.deepEqual(boardScenes(off, false, false), ['departures']);
|
|
assert.deepEqual(boardScenes({ ...off, adsEnabled: true }, false, false), ['departures', 'ad']);
|
|
assert.deepEqual(boardScenes({ ...off, adsEnabled: true }, true, true), ['departures', 'info']);
|
|
assert.deepEqual(boardScenes(off, true, false), ['departures', 'info']);
|
|
});
|