package com.ruoyi.web.modules.order.support;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import com.ruoyi.web.modules.order.constant.OrderAppConstants;
import com.ruoyi.web.modules.order.constant.OrderConstants;
import com.ruoyi.web.modules.order.domain.BizOrder;

@ExtendWith(MockitoExtension.class)
class OrderAppSupportTest
{
    @InjectMocks
    private OrderAppSupport orderAppSupport;

    @Test
    void toStatusText_mapsPendingPay()
    {
        assertEquals("待付款", orderAppSupport.toStatusText(OrderConstants.STATUS_PENDING_PAY));
    }

    @Test
    void resolveReviewStatus_completedWithoutReview_isPending()
    {
        BizOrder order = new BizOrder();
        order.setOrderStatus(OrderConstants.STATUS_COMPLETED);
        assertEquals(OrderAppConstants.REVIEW_STATUS_PENDING,
                orderAppSupport.resolveReviewStatus(order, null));
    }

    @Test
    void resolveActions_pendingPay_containsPay()
    {
        BizOrder order = new BizOrder();
        order.setOrderStatus(OrderConstants.STATUS_PENDING_PAY);
        List<String> actions = orderAppSupport.resolveActions(order, null);
        assertTrue(actions.contains(OrderAppConstants.ACTION_PAY));
    }

    @Test
    void joinAndSplitPics_roundTrip()
    {
        String joined = orderAppSupport.joinPics(Arrays.asList("a.jpg", "b.jpg"));
        assertEquals(2, orderAppSupport.splitPics(joined).size());
    }
}
