package com.gxwebsoft.house.util;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
 * SortSceneUtil测试类
 * 
 * @author 科技小王子
 * @since 2025-08-04
 */
public class SortSceneUtilTest {

    @Test
    public void testNormalizeSortScene() {
        // 测试URL编码的参数
        String urlEncoded = "%E4%BB%B7%E6%A0%BC(%E4%BD%8E-%E9%AB%98)";
        String result = SortSceneUtil.normalizeSortScene(urlEncoded);
        assertEquals("价格(低-高)", result);
        
        // 测试已解码的参数
        String decoded = "价格(低-高)";
        result = SortSceneUtil.normalizeSortScene(decoded);
        assertEquals("价格(低-高)", result);
        
        // 测试空值
        result = SortSceneUtil.normalizeSortScene(null);
        assertNull(result);
        
        result = SortSceneUtil.normalizeSortScene("");
        assertNull(result);
        
        result = SortSceneUtil.normalizeSortScene("   ");
        assertNull(result);
    }
    
    @Test
    public void testIsPriceAsc() {
        assertTrue(SortSceneUtil.isPriceAsc("价格(低-高)"));
        assertTrue(SortSceneUtil.isPriceAsc("%E4%BB%B7%E6%A0%BC(%E4%BD%8E-%E9%AB%98)"));
        assertFalse(SortSceneUtil.isPriceAsc("价格(高-低)"));
        assertFalse(SortSceneUtil.isPriceAsc("最新发布"));
    }
    
    @Test
    public void testIsPriceDesc() {
        assertTrue(SortSceneUtil.isPriceDesc("价格(高-低)"));
        assertFalse(SortSceneUtil.isPriceDesc("价格(低-高)"));
        assertFalse(SortSceneUtil.isPriceDesc("最新发布"));
    }
    
    @Test
    public void testIsLatest() {
        assertTrue(SortSceneUtil.isLatest("最新发布"));
        assertFalse(SortSceneUtil.isLatest("价格(低-高)"));
    }
    
    @Test
    public void testIsComprehensive() {
        assertTrue(SortSceneUtil.isComprehensive("综合排序"));
        assertFalse(SortSceneUtil.isComprehensive("价格(低-高)"));
    }
}
