33import org .junit .jupiter .api .BeforeEach ;
44import org .junit .jupiter .api .Test ;
55
6- import static org .assertj .core .api .Assertions .assertThat ;
7- import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
6+ import static org .junit .jupiter .api .Assertions .assertEquals ;
7+ import static org .junit .jupiter .api .Assertions .assertFalse ;
8+ import static org .junit .jupiter .api .Assertions .assertThrows ;
9+ import static org .junit .jupiter .api .Assertions .assertTrue ;
810
911class MarkdownFormatterTest {
1012
@@ -17,44 +19,48 @@ void setUp() {
1719
1820 @ Test
1921 void formatWhenFormattingPlainTextThenReturnsTextWrappedInParagraph () {
20- assertThat ( markdownFormatter . format ( "Hello World" )). isEqualTo ( " <p>Hello World</p>" );
22+ assertEquals ( " <p>Hello World</p>", markdownFormatter . format ( "Hello World" ) );
2123 }
2224
2325 @ Test
2426 void formatWhenFormattingComplexMarkupThenReturnsOnlyOneLine () {
2527 String source = "Markup\n \n * list item one\n * list item 2\n \n rest" ;
26- assertThat (markdownFormatter .format (source ))
27- .contains ("Markup<br />" )
28- .contains ("<li>list item one</li>" )
29- .contains ("<li>list item 2</li>" )
30- .contains ("> rest" )
31- .doesNotContain ("\n " );
28+
29+ String actual = markdownFormatter .format (source );
30+
31+ // Only test relevant bits and ignore possible whitespace introduced by html-renderer
32+ assertTrue (actual .contains ("Markup<br />" ));
33+ assertTrue (actual .contains ("<li>list item one</li>" ));
34+ assertTrue (actual .contains ("<li>list item 2</li>" ));
35+ assertTrue (actual .contains ("> rest" ));
36+ assertFalse (actual .contains ("\n " ));
3237 }
3338
3439 @ Test
3540 void formatWhenFormattingEmptyStringThenReturnsEmptyString () {
36- assertThat ( markdownFormatter .format ("" )). isEqualTo ( "" );
41+ assertEquals ( "" , markdownFormatter .format ("" ));
3742 }
3843
3944 @ Test
4045 void formatWhenFormattingNullThenThrowsException () {
41- assertThatExceptionOfType (NullPointerException .class ).isThrownBy (() -> markdownFormatter .format (null ))
42- .withMessageContaining ("Field Text should not be null, when handed to formatter" )
43- .withNoCause ();
46+ Exception exception = assertThrows (NullPointerException .class , () -> markdownFormatter .format (null ));
47+ assertEquals ("Field Text should not be null, when handed to formatter" , exception .getMessage ());
4448 }
4549
4650 @ Test
4751 void formatWhenMarkupContainingStrikethroughThenContainsMatchingDel () {
48- assertThat (markdownFormatter .format ("a ~~b~~ b" )).contains ("<del>b</del>" );
52+ // Only test strikethrough extension
53+ assertTrue (markdownFormatter .format ("a ~~b~~ b" ).contains ("<del>b</del>" ));
4954 }
5055
5156 @ Test
5257 void formatWhenMarkupContainingTaskListThenContainsFormattedTaskList () {
53- assertThat ( markdownFormatter .format ("Some text\n " +
58+ String actual = markdownFormatter .format ("Some text\n " +
5459 "* [ ] open task\n " +
5560 "* [x] closed task\n \n " +
56- "some other text" ))
57- .contains ("<li class=\" task-list-item\" ><input type=\" checkbox\" class=\" task-list-item-checkbox\" disabled=\" disabled\" readonly=\" readonly\" /> open task</li>" )
58- .contains ("<li class=\" task-list-item\" ><input type=\" checkbox\" class=\" task-list-item-checkbox\" checked=\" checked\" disabled=\" disabled\" readonly=\" readonly\" /> closed task</li>" );
61+ "some other text" );
62+ // Only test list items
63+ assertTrue (actual .contains ("<li class=\" task-list-item\" ><input type=\" checkbox\" class=\" task-list-item-checkbox\" disabled=\" disabled\" readonly=\" readonly\" /> open task</li>" ));
64+ assertTrue (actual .contains ("<li class=\" task-list-item\" ><input type=\" checkbox\" class=\" task-list-item-checkbox\" checked=\" checked\" disabled=\" disabled\" readonly=\" readonly\" /> closed task</li>" ));
5965 }
6066}
0 commit comments