ci/woodpecker/push/woodpecker Pipeline was successful
Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
24 lines
1.3 KiB
TypeScript
24 lines
1.3 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { getPathSet, getRouteKey, resolveCanonicalUrl } from './routing.js';
|
|
|
|
test('normalizes legacy asset paths without losing search parameters', () => {
|
|
assert.equal(resolveCanonicalUrl({ pathname: '/mileage', search: '?date=2026-08-12', hash: '' }), '/asset?date=2026-08-12#mileage');
|
|
assert.equal(resolveCanonicalUrl({ pathname: '/unknown', search: '?x=1', hash: '#mileage' }), '/asset?x=1#mileage');
|
|
});
|
|
test('keeps canonical and hidden administration paths unchanged', () => {
|
|
assert.equal(resolveCanonicalUrl({ pathname: '/asset', search: '', hash: '#assets' }), null);
|
|
assert.equal(resolveCanonicalUrl({ pathname: '/admin/feedback', search: '', hash: '' }), null);
|
|
assert.equal(resolveCanonicalUrl({ pathname: '/energy/hydrogen-board', search: '', hash: '' }), null);
|
|
});
|
|
|
|
test('derives path groups and hidden routes from path or hash', () => {
|
|
assert.equal(getPathSet('/energy'), 'energy');
|
|
assert.equal(getPathSet('/energy/hydrogen-board'), 'energy');
|
|
assert.equal(getPathSet('/asset'), 'asset');
|
|
assert.equal(getRouteKey('/energy/hydrogen-board', ''), 'energy/hydrogen-board');
|
|
assert.equal(getRouteKey('/asset', '#/ele/import'), 'ele/import');
|
|
assert.equal(getRouteKey('/admin/feedback', ''), 'admin/feedback');
|
|
assert.equal(getRouteKey('/asset', '#mileage'), '');
|
|
});
|