import assert from 'node:assert/strict'
import test from 'node:test'

import { resolveLegacyWorkerPath } from '../src/utils/worker-routes.ts'

test('旧打手地址映射到子域名短路径', () => {
  assert.equal(resolveLegacyWorkerPath('#/worker/login'), '/')
  assert.equal(resolveLegacyWorkerPath('#/worker/hall'), '/hall')
  assert.equal(resolveLegacyWorkerPath('#/worker/orders'), '/orders')
  assert.equal(resolveLegacyWorkerPath('#/worker/profile'), '/profile')
})

test('旧打手地址保留查询参数', () => {
  assert.equal(
    resolveLegacyWorkerPath('#/worker/orders?status=in_progress'),
    '/orders?status=in_progress',
  )
})

test('非打手地址不触发跨域跳转', () => {
  assert.equal(resolveLegacyWorkerPath('#/admin/dashboard'), '')
  assert.equal(resolveLegacyWorkerPath('#/claim/example'), '')
})
