/*
* SonarQube
* Copyright (C) 2009-2023 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.markdown;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class MarkdownTest {
@Test
public void shouldDecorateAbsoluteUrl() {
assertThat(Markdown.convertToHtml("http://google.com"))
.isEqualTo("http://google.com");
}
@Test
public void shouldDecorateRelativeUrl() {
assertThat(Markdown.convertToHtml("[Google](/google/com)"))
.isEqualTo("Google");
}
@Test
public void shouldDecorateDocumentedLink() {
assertThat(Markdown.convertToHtml("For more details, please [check online documentation](http://docs.sonarsource.com/sonarqube/display/SONAR)."))
.isEqualTo("For more details, please check online documentation.");
}
@Test
public void shouldDecorateEndOfLine() {
assertThat(Markdown.convertToHtml("1\r2\r\n3\n")).isEqualTo("1
2
3
");
}
@Test
public void shouldDecorateUnorderedList() {
assertThat(Markdown.convertToHtml(" * one\r* two\r\n* three\n * \n *five"))
.isEqualTo("
Yesterday <br/> it worked"); assertThat(Markdown.convertToHtml("HTML elements should not be quoted!")) .isEqualTo("HTML elements should <em>not</em> be quoted!"); } @Test public void shouldDecorateMixedOrderedAndUnorderedList() { assertThat(Markdown.convertToHtml(" 1. one\r* two\r\n1. three\n * \n 1.five")) .isEqualTo("
\nToday it is not working
\r\nSoftware is like that
\r
line of code
");
assertThat(Markdown.convertToHtml("This is not a ``line of code")).isEqualTo("This is not a ``line of code");
}
@Test
public void shouldDecorateMultipleLineCode() {
assertThat(Markdown.convertToHtml("This is a ``\nline of code\nOn multiple lines\n``")).isEqualTo("This is a line of code\nOn multiple lines
");
assertThat(Markdown.convertToHtml("This is not a ``line of code\nOn multiple lines``")).isEqualTo("This is not a ``line of codeline of code\nOn multiple lines
");
assertThat(Markdown.convertToHtml("This is not a ``java line of code\nOn multiple lines``")).isEqualTo("This is not a ``java line of code