Skip to content

Commit

Permalink
test(table): Add Test to ensure Tables are properly rendered when pos…
Browse files Browse the repository at this point in the history
…itioned under a paragraph
  • Loading branch information
EDGA6280 committed May 31, 2023
1 parent 1889aab commit 4f64256
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/test/java/nl/jworks/markdown_to_asciidoc/TestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.nio.charset.StandardCharsets;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
Expand All @@ -22,6 +26,17 @@ public void test() {
assertEquals(readToString("testsuite.adoc"), asciiDoc);
}


@Test
public void readme() throws IOException {
String markDown = readToString("Readme.md");
String asciiDoc = Converter.markdownToAsciiDoc(markDown);


toFile(asciiDoc, new File("target/readme.adoc"));
//assertEquals(readToString("testsuite.adoc"), asciiDoc);
}

private String readToString(String resourceName) {
URL url = getClass().getResource("/" + resourceName);
try {
Expand All @@ -31,4 +46,22 @@ private String readToString(String resourceName) {
return null;
}
}

public void toFile(String buffer, File file) throws IOException {

OutputStreamWriter bwr = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);

toFile(buffer, bwr);
}

private void toFile(String buffer, OutputStreamWriter bwr) throws IOException {
//write contents of StringBuffer to a file
bwr.write(buffer);

//flush the stream
bwr.flush();

//close the stream
bwr.close();
}
}
30 changes: 30 additions & 0 deletions src/test/resources/nl/jworks/markdown_to_asciidoc/tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@ Feature: Tables
|===
"""

Scenario: Render a table under a paragraph
Given the Markdown source
"""
# Step
Lorem Ipsum etc.
- `sample.yaml`: sample file to do some stuff with
| Name of Column 1 | Name of Column 2|
| ---------------- | --------------- |
| Cell in column 1, row 1 | Cell in column 2, row 1|
| Cell in column 1, row 2 | Cell in column 2, row 2|
"""
When it is converted to AsciiDoc
Then the result should match the AsciiDoc source
"""
= Step
Lorem Ipsum etc.
* `sample.yaml`: sample file to do some stuff with
|===
|Name of Column 1 |Name of Column 2
|Cell in column 1, row 1 |Cell in column 2, row 1
|Cell in column 1, row 2 |Cell in column 2, row 2
|===
"""

# NOTE we are still getting trailing space at the end of lines
Scenario: Leave a trailing space at the end of each adjacent cell
Given the Markdown source
Expand Down

0 comments on commit 4f64256

Please sign in to comment.