nestedRouteUtils.test.mjs 951 B

123456789101112131415161718192021222324252627282930
  1. import assert from 'node:assert/strict'
  2. import { toNestedRoutePath } from '../src/router/nestedRouteUtils.js'
  3. const rootPath = '/subSystem/pipeNetwork'
  4. assert.equal(
  5. toNestedRoutePath('/subSystem/pipeNetwork/pdeviceInform/netWorkBase', rootPath),
  6. 'pdeviceInform/netWorkBase',
  7. 'canonical absolute paths must become relative to the subsystem root'
  8. )
  9. assert.equal(
  10. toNestedRoutePath('/pipeNetwork/pdeviceInform/netWorkBase', rootPath),
  11. 'pdeviceInform/netWorkBase',
  12. 'legacy pipeNetwork prefixes must not be duplicated below the new subsystem root'
  13. )
  14. assert.equal(
  15. toNestedRoutePath('/pdeviceInform/netWorkBase', rootPath),
  16. 'pdeviceInform/netWorkBase',
  17. 'already-relative menu paths must remain unchanged'
  18. )
  19. assert.equal(
  20. toNestedRoutePath('/assetInfo/pdeviceInform/netWorkBase', rootPath),
  21. 'assetInfo/pdeviceInform/netWorkBase',
  22. 'unrelated directory segments must remain intact'
  23. )
  24. console.log('nestedRouteUtils tests passed')