package com.tencent.qian.webview;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * 语言偏好 {@code appendLang} 纯逻辑单测（L4 转发场景）。
 * 与 Kotlin / iOS / OC 的 appendLang 用例对齐。
 */
public class PrewarmLangTest {

    @Test public void appendLang_withExistingQuery_usesAmpersand() {
        assertEquals(
                "https://quick.qian.tencent.com/warmup.html?bizType=single-sign&lang=en-US",
                TencentQianWebViewPrewarmer.appendLang(
                        "https://quick.qian.tencent.com/warmup.html?bizType=single-sign", "en-US"));
    }

    @Test public void appendLang_withoutQuery_usesQuestionMark() {
        assertEquals(
                "https://quick.qian.tencent.com/warmup.html?lang=zh-CN",
                TencentQianWebViewPrewarmer.appendLang(
                        "https://quick.qian.tencent.com/warmup.html", "zh-CN"));
    }

    @Test public void appendLang_emptyOrNull_returnsUrlUnchanged() {
        String url = "https://quick.qian.tencent.com/warmup.html?bizType=x";
        assertEquals(url, TencentQianWebViewPrewarmer.appendLang(url, null));
        assertEquals(url, TencentQianWebViewPrewarmer.appendLang(url, ""));
    }
}
