import { describe, expect, test } from "bun:test"
import {
  APP_NAME,
  CLI_COMMAND,
  LOG_PREFIX,
  PACKAGE_NAME,
  RUNTIME_PROFILE_ENV_VAR,
  SDK_CLIENT_APP,
  getDataDir,
  getDataDirDisplay,
  getDataRootName,
  getCliInvocation,
  getRuntimeProfile,
} from "./branding"

describe("runtime profile helpers", () => {
  test("defaults to the prod profile when unset", () => {
    expect(APP_NAME).toBe("Airaknit")
    expect(CLI_COMMAND).toBe("airaknit")
    expect(PACKAGE_NAME).toBe("airaknit")
    expect(LOG_PREFIX).toBe("[airaknit]")
    expect(SDK_CLIENT_APP).toStartWith("airaknit/")
    expect(getCliInvocation("--port 4000")).toBe("airaknit --port 4000")
    expect(getRuntimeProfile({})).toBe("prod")
    expect(getDataRootName({})).toBe(".airaknit")
    expect(getDataDir("/tmp/home", {})).toBe("/tmp/home/.airaknit/data")
    expect(getDataDirDisplay({})).toBe("~/.airaknit/data")
  })

  test("switches to dev paths for the dev profile", () => {
    const env = { [RUNTIME_PROFILE_ENV_VAR]: "dev" }

    expect(getRuntimeProfile(env)).toBe("dev")
    expect(getDataRootName(env)).toBe(".airaknit-dev")
    expect(getDataDir("/tmp/home", env)).toBe("/tmp/home/.airaknit-dev/data")
    expect(getDataDirDisplay(env)).toBe("~/.airaknit-dev/data")
  })

  test("still honors the legacy runtime profile environment variable for compatibility", () => {
    expect(getRuntimeProfile({ KANNA_RUNTIME_PROFILE: "dev" })).toBe("dev")
  })
})
