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

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collections;
import org.junit.jupiter.api.Test;

class GoodsPicSupportTest
{
    @Test
    void buildGalleryPics_mainPicOnly()
    {
        assertEquals(Collections.singletonList("/main.jpg"),
                GoodsPicSupport.buildGalleryPics("/main.jpg", null));
    }

    @Test
    void buildGalleryPics_mainAndSubPics()
    {
        assertEquals(Arrays.asList("/main.jpg", "/sub1.jpg", "/sub2.jpg"),
                GoodsPicSupport.buildGalleryPics("/main.jpg", Arrays.asList("/sub1.jpg", "/sub2.jpg")));
    }

    @Test
    void buildGalleryPics_noMainPic()
    {
        assertEquals(Collections.singletonList("/sub1.jpg"),
                GoodsPicSupport.buildGalleryPics(null, Collections.singletonList("/sub1.jpg")));
    }

    @Test
    void buildGalleryPics_skipsBlankSubUrls()
    {
        assertEquals(Arrays.asList("/main.jpg", "/sub1.jpg"),
                GoodsPicSupport.buildGalleryPics("/main.jpg", Arrays.asList("/sub1.jpg", "  ", "")));
    }

    @Test
    void buildGalleryPics_emptyWhenNoUrls()
    {
        assertTrue(GoodsPicSupport.buildGalleryPics(null, null).isEmpty());
    }
}
