import assert from 'node:assert/strict'

let mergeRouteRecords

try {
  ({ mergeRouteRecords } = await import('../src/router/routeUtils.js'))
} catch {
  // The first RED run intentionally reaches this branch before the helper exists.
}

assert.equal(typeof mergeRouteRecords, 'function', 'route modules must be merged by a route-record helper')

const baseRoutes = [{ path: '/login' }]
const waterSupplyRoutes = [{ path: '/waterSupply' }]
const mergedRoutes = mergeRouteRecords(baseRoutes, waterSupplyRoutes)

assert.deepEqual(
  mergedRoutes.map(route => route.path),
  ['/login', '/waterSupply'],
  'route module arrays must be expanded into top-level route records'
)
assert.ok(mergedRoutes.every(route => !Array.isArray(route)), 'top-level routes must not contain nested arrays')

console.log('routerRouteUtils tests passed')
