import { describe, expect, it } from 'vitest'
import { resolveExplorerApiBase } from '@/libs/frontend-api-client/api-base'
import { getPublicExplorerBase } from '@/utils/publicExplorer'

describe('getPublicExplorerBase', () => {
  it('matches resolveExplorerApiBase with explorer.d-bis.org SSR fallback', () => {
    expect(getPublicExplorerBase()).toBe(
      resolveExplorerApiBase({
        envValue: process.env.NEXT_PUBLIC_API_URL,
        serverFallback: 'https://explorer.d-bis.org',
      }),
    )
  })

  it('does not default to blockscout.defi-oracle.io when env is empty on the server', () => {
    expect(getPublicExplorerBase()).not.toBe('https://blockscout.defi-oracle.io')
  })
})
