import assert from 'node:assert/strict'
import { ensureUniqueSubsystemRouteNames } from '../src/router/routeNameUtils.js'

const routes = ensureUniqueSubsystemRouteNames([
  {
    path: '/subSystem/waterSupply',
    name: 'WaterSupply',
    children: [
      { path: 'index', name: 'Index' },
      { path: 'facility/gis', name: 'Gis' },
      { path: 'device/gis', name: 'Gis' }
    ]
  }
])

assert.deepEqual(
  [routes[0].name, ...routes[0].children.map(route => route.name)],
  ['SubSystemWaterSupply', 'SubSystemWaterSupplyIndex', 'SubSystemWaterSupplyFacilityGis', 'SubSystemWaterSupplyDeviceGis']
)
assert.equal(new Set([routes[0].name, ...routes[0].children.map(route => route.name)]).size, 4)

console.log('routeNameUtils tests passed')
