implements PLN-0095
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
package p.studio.compiler.pbs;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class PbsDocumentationTextBlockNormalizerTest {
|
||||
|
||||
@Test
|
||||
void shouldNormalizeIncidentalBoundaryLinesAndIndentation() {
|
||||
final var lexeme = "\"\"\"\n" +
|
||||
" Draws a sprite.\n" +
|
||||
"\n" +
|
||||
" - `x`: screen x\n" +
|
||||
" - `y`: screen y\n" +
|
||||
" \"\"\"";
|
||||
|
||||
final var normalized = PbsDocumentationTextBlockNormalizer.normalizeLexeme(lexeme);
|
||||
|
||||
assertEquals("Draws a sprite.\n\n- `x`: screen x\n- `y`: screen y", normalized);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPreserveInternalLineBreaksAndMarkdownContent() {
|
||||
final var content = "\n" +
|
||||
" Paragraph one.\n" +
|
||||
" \n" +
|
||||
" `code_span()`\n" +
|
||||
" Paragraph two.\n";
|
||||
|
||||
final var normalized = PbsDocumentationTextBlockNormalizer.normalizeContent(content);
|
||||
|
||||
assertEquals("Paragraph one.\n\n`code_span()`\nParagraph two.", normalized);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnEmptyStringForWhitespaceOnlyPayload() {
|
||||
final var normalized = PbsDocumentationTextBlockNormalizer.normalizeLexeme("\"\"\"\n \n \t\n\"\"\"");
|
||||
|
||||
assertEquals("", normalized.trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNormalizeCarriageReturnLineEndings() {
|
||||
final var normalized = PbsDocumentationTextBlockNormalizer.normalizeContent("\r\n\tLine one\r\n\tLine two\r\n");
|
||||
|
||||
assertEquals("Line one\nLine two", normalized);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnEmptyStringForMalformedLexeme() {
|
||||
assertEquals("", PbsDocumentationTextBlockNormalizer.normalizeLexeme("\"not a text block\""));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user