Skip to content

Commit 3897e88

Browse files
committed
add markdown test
1 parent c2605fe commit 3897e88

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class CitationStyleGeneratorTest {
2727
private static final String DEFAULT_STYLE = CSLStyleLoader.getDefaultStyle().getSource();
2828
private static final CitationStyleOutputFormat HTML_OUTPUT_FORMAT = CitationStyleOutputFormat.HTML;
2929
private static final CitationStyleOutputFormat TEXT_OUTPUT_FORMAT = CitationStyleOutputFormat.TEXT;
30+
private static final CitationStyleOutputFormat MARKDOWN_OUTPUT_FORMAT = CitationStyleOutputFormat.MARKDOWN;
3031
private static final BibEntryTypesManager ENTRY_TYPES_MANAGER = new BibEntryTypesManager();
3132

3233
private final BibEntry testEntry = TestEntry.getTestEntry();
@@ -150,9 +151,11 @@ void ignoreCarriageReturnNewLine() {
150151
entry.setField(StandardField.AUTHOR, "Last, First and\r\nDoe, Jane");
151152

152153
// if the default citation style changes this has to be modified
153-
String expected = " <div class=\"csl-entry\">\n" +
154-
" <div class=\"csl-left-margin\">[1]</div><div class=\"csl-right-inline\">F. Last and J. Doe, </div>\n" +
155-
" </div>\n";
154+
String expected = """
155+
<div class="csl-entry">
156+
<div class="csl-left-margin">[1]</div><div class="csl-right-inline">F. Last and J. Doe, </div>
157+
</div>
158+
""";
156159
String citation = CitationStyleGenerator.generateBibliography(List.of(entry), DEFAULT_STYLE, ENTRY_TYPES_MANAGER);
157160
assertEquals(expected, citation);
158161
}
@@ -168,9 +171,11 @@ void missingCitationStyle() {
168171

169172
@Test
170173
void htmlFormat() {
171-
String expectedCitation = " <div class=\"csl-entry\">\n" +
172-
" <div class=\"csl-left-margin\">[1]</div><div class=\"csl-right-inline\">B. Smith, B. Jones, and J. Williams, &ldquo;Title of the test entry,&rdquo; <span style=\"font-style: italic\">BibTeX Journal</span>, vol. 34, no. 3, pp. 45&ndash;67, July 2016, doi: 10.1001/bla.blubb.</div>\n" +
173-
" </div>\n";
174+
String expectedCitation = """
175+
<div class="csl-entry">
176+
<div class="csl-left-margin">[1]</div><div class="csl-right-inline">B. Smith, B. Jones, and J. Williams, &ldquo;Title of the test entry,&rdquo; <span style="font-style: italic">BibTeX Journal</span>, vol. 34, no. 3, pp. 45&ndash;67, July 2016, doi: 10.1001/bla.blubb.</div>
177+
</div>
178+
""";
174179

175180
String actualCitation = CitationStyleGenerator.generateBibliography(List.of(testEntry), DEFAULT_STYLE, HTML_OUTPUT_FORMAT, testEntryContext, ENTRY_TYPES_MANAGER).getFirst();
176181
assertEquals(expectedCitation, actualCitation);
@@ -184,6 +189,14 @@ void textFormat() {
184189
assertEquals(expectedCitation, actualCitation);
185190
}
186191

192+
@Test
193+
void markdownFormat() {
194+
String expectedCitation = "\\[1\\]B\\. Smith\\, B\\. Jones\\, and J\\. Williams\\, “Title of the test entry\\,” *BibTeX Journal*\\, vol\\. 34\\, no\\. 3\\, pp\\. 45–67\\, Jul\\. 2016\\, doi\\: 10\\.1001\\/bla\\.blubb\\.<br />\n";
195+
196+
String actualCitation = CitationStyleGenerator.generateBibliography(List.of(testEntry), DEFAULT_STYLE, MARKDOWN_OUTPUT_FORMAT, testEntryContext, ENTRY_TYPES_MANAGER).getFirst();
197+
assertEquals(expectedCitation, actualCitation);
198+
}
199+
187200
@Test
188201
void handleDiacritics() {
189202
BibEntry entry = new BibEntry();
@@ -192,9 +205,11 @@ void handleDiacritics() {
192205

193206
// if the default citation style changes this has to be modified.
194207
// in this case ä was added to check if it is formatted appropriately
195-
String expected = " <div class=\"csl-entry\">\n" +
196-
" <div class=\"csl-left-margin\">[1]</div><div class=\"csl-right-inline\">F. L&auml;st and J. Doe, </div>\n" +
197-
" </div>\n";
208+
String expected = """
209+
<div class="csl-entry">
210+
<div class="csl-left-margin">[1]</div><div class="csl-right-inline">F. L&auml;st and J. Doe, </div>
211+
</div>
212+
""";
198213
String citation = CitationStyleGenerator.generateBibliography(List.of(entry), DEFAULT_STYLE, ENTRY_TYPES_MANAGER);
199214
assertEquals(expected, citation);
200215
}

0 commit comments

Comments
 (0)