package p.studio.compiler.pbs;

import org.junit.jupiter.api.Test;
import p.studio.compiler.PBSDefinitions;

import java.net.URL;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

final class PbsSemanticPresentationContractTest {

    @Test
    void shouldPublishSemanticPresentationContractThroughFrontendSpec() {
        final var presentation = PBSDefinitions.PBS.getSemanticPresentation();

        assertFalse(presentation.semanticKeys().isEmpty());
        assertEquals(PbsSemanticKind.semanticKeys(), presentation.semanticKeys());
        assertEquals(1, presentation.resources().size());
        assertEquals("/themes/pbs/semantic-highlighting.css", presentation.resources().getFirst());
    }

    @Test
    void shouldPublishResolvableSemanticPresentationResources() {
        final var resourcePath = PBSDefinitions.PBS.getSemanticPresentation().resources().getFirst();
        final URL resource = PBSDefinitions.class.getResource(resourcePath);

        assertNotNull(resource, resourcePath);
        assertTrue(resource.toExternalForm().endsWith("themes/pbs/semantic-highlighting.css"));
    }
}
