package io.ljunggren.html.utils;
import static org.junit.Assert.*;
import org.junit.Test;
public class HtmlUtilsTest {
@Test
public void prettyPrintTest() {
String expected = "<html>\n"
+ " <head></head>\n"
+ " <body>\n"
+ " Hello World\n"
+ " </body>\n"
+ "</html>";
String actual = HtmlUtils.prettyPrint("<html><body>Hello World</body><html>");
assertEquals(expected, actual);
}
@Test
public void prettyPrintNullTest() {
String actual = HtmlUtils.prettyPrint(null);
assertNull(actual);
}
@Test
public void prettyPrintWithDefinedSpacingTest() {
String expected = "<html>\n"
+ " <head></head>\n"
+ " <body>\n"
+ " Hello World\n"
+ " </body>\n"
+ "</html>";
String actual = HtmlUtils.prettyPrint("<html><body>Hello World</body><html>", 2);
assertEquals(expected, actual);
}
@Test
public void prettyPrintWithDefinedSpacingNullTest() {
String actual = HtmlUtils.prettyPrint(null, 2);
assertNull(actual);
}
@Test
public void prettyPrintWithNegativeValueTest() {
String expected = "<html>\n"
+ "<head></head>\n"
+ "<body>\n"
+ "Hello World\n"
+ "</body>\n"
+ "</html>";
String actual = HtmlUtils.prettyPrint("<html><body>Hello World</body><html>", -2);
assertEquals(expected, actual);
}
}