package click.kamil.springstatemachineexporter.html.exporter;

import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

public class SvgDecoratorTest {

    private final SvgDecorator decorator = new SvgDecorator();

    @Test
    void shouldMakeSvgResponsive() {
        String rawSvg = "<svg width=\"500px\" height=\"300px\" style=\"width:500px;height:300px;background:#FFF;\" version=\"1.1\"><defs/></svg>";
        String decorated = decorator.decorate(rawSvg);
        
        assertThat(decorated).doesNotContain("width=\"500px\"");
        assertThat(decorated).doesNotContain("height=\"300px\"");
        assertThat(decorated).doesNotContain("style=\"width:500px;height:300px;background:#FFF;\"");
    }

    @Test
    void shouldNotTouchInternalElementDimensions() {
        // The decorator replaces the FIRST width/height it finds in the root <svg> tag
        String rawSvg = "<svg width=\"500\" height=\"500\"><defs></defs><rect width=\"10\" height=\"10\"/></svg>";
        String decorated = decorator.decorate(rawSvg);
        
        assertThat(decorated).contains("width=\"100%\"");
        assertThat(decorated).contains("height=\"100%\"");
        assertThat(decorated).contains("<rect width=\"10\" height=\"10\"/>");
    }

    @Test
    void shouldInjectInteractivityStyles() {
        String rawSvg = "<svg><defs></defs></svg>";
        String decorated = decorator.decorate(rawSvg);
        
        assertThat(decorated).contains(".active-path");
        assertThat(decorated).contains(".dimmed");
        assertThat(decorated).contains("@keyframes sm-flow");
    }
}
