jest.mock('next-intl/middleware', () => jest.fn(() => jest.fn()))
jest.mock('@/i18n/routing', () => ({ routing: {} }))

let proxyHandler!: typeof import('@/proxy').default
let proxyConfig!: typeof import('@/proxy').config

beforeAll(async () => {
  const mod = await import('@/proxy')
  proxyHandler = mod.default
  proxyConfig = mod.config
})

describe('proxy (i18n middleware)', () => {
  describe('config.matcher — contract (API / static exclusions)', () => {
    it.each([
      ['api', 'excludes API routes'],
      ['trpc', 'excludes tRPC'],
      ['_next', 'excludes Next internals'],
      ['_vercel', 'excludes Vercel'],
    ] as const)('matcher negation includes %s (%s)', (fragment) => {
      expect(proxyConfig.matcher).toEqual(expect.stringContaining(fragment))
    })

    it('matcher excludes segment with dot (static file pattern)', () => {
      expect(proxyConfig.matcher).toContain('\\.') // `.*\..*` inside source
    })
  })

  describe('default export — happy path', () => {
    it('is a function (next-intl middleware factory)', () => {
      expect(typeof proxyHandler).toBe('function')
    })
  })
})
