Add test cases for all avaialble elements (single)
This commit is contained in:
parent
caf7f99335
commit
ba30654728
@ -18,6 +18,7 @@ import ru.noties.markwon.Markwon;
|
|||||||
import ru.noties.markwon.SpannableBuilder;
|
import ru.noties.markwon.SpannableBuilder;
|
||||||
import ru.noties.markwon.SpannableConfiguration;
|
import ru.noties.markwon.SpannableConfiguration;
|
||||||
import ru.noties.markwon.SpannableFactory;
|
import ru.noties.markwon.SpannableFactory;
|
||||||
|
import ru.noties.markwon.html.api.MarkwonHtmlParser;
|
||||||
import ru.noties.markwon.renderer.SpannableMarkdownVisitor;
|
import ru.noties.markwon.renderer.SpannableMarkdownVisitor;
|
||||||
import ru.noties.markwon.spans.SpannableTheme;
|
import ru.noties.markwon.spans.SpannableTheme;
|
||||||
|
|
||||||
@ -134,11 +135,15 @@ public class SpannableMarkdownVisitorTest {
|
|||||||
private SpannableConfiguration configuration(@NonNull TestConfig config) {
|
private SpannableConfiguration configuration(@NonNull TestConfig config) {
|
||||||
|
|
||||||
final SpannableFactory factory = new TestFactory(config.hasOption(TestConfig.USE_PARAGRAPHS));
|
final SpannableFactory factory = new TestFactory(config.hasOption(TestConfig.USE_PARAGRAPHS));
|
||||||
|
final MarkwonHtmlParser htmlParser = config.hasOption(TestConfig.USE_HTML)
|
||||||
|
? null
|
||||||
|
: MarkwonHtmlParser.noOp();
|
||||||
|
|
||||||
// todo: rest omitted for now
|
// todo: rest omitted for now
|
||||||
return SpannableConfiguration.builder(null)
|
return SpannableConfiguration.builder(null)
|
||||||
.theme(mock(SpannableTheme.class))
|
.theme(mock(SpannableTheme.class))
|
||||||
.linkResolver(mock(LinkResolverDef.class))
|
.linkResolver(mock(LinkResolverDef.class))
|
||||||
|
.htmlParser(htmlParser)
|
||||||
.factory(factory)
|
.factory(factory)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,14 @@ abstract class TestDataReader {
|
|||||||
if (object != null) {
|
if (object != null) {
|
||||||
attributes = new HashMap<>(object.size());
|
attributes = new HashMap<>(object.size());
|
||||||
for (String key : object.keySet()) {
|
for (String key : object.keySet()) {
|
||||||
attributes.put(key, object.get(key).getAsString());
|
final String value;
|
||||||
|
final JsonElement valueElement = object.get(key);
|
||||||
|
if (valueElement.isJsonNull()) {
|
||||||
|
value = null;
|
||||||
|
} else {
|
||||||
|
value = valueElement.getAsString();
|
||||||
|
}
|
||||||
|
attributes.put(key, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attributes = Collections.emptyMap();
|
attributes = Collections.emptyMap();
|
||||||
|
15
markwon/src/test/resources/tests/deeply-nested.yaml
Normal file
15
markwon/src/test/resources/tests/deeply-nested.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
input: |-
|
||||||
|
**bold *bold italic ~~bold italic strike `bold italic strike code` bold italic strike~~ bold italic* bold** normal
|
||||||
|
|
||||||
|
output:
|
||||||
|
- b:
|
||||||
|
- text: "bold "
|
||||||
|
- i:
|
||||||
|
- text: "bold italic "
|
||||||
|
- s:
|
||||||
|
- text: "bold italic strike "
|
||||||
|
- code: "bold italic strike code"
|
||||||
|
- text: " bold italic strike"
|
||||||
|
- text: " bold italic"
|
||||||
|
- text: " bold"
|
||||||
|
- text: " normal"
|
@ -12,8 +12,7 @@ config:
|
|||||||
|
|
||||||
output:
|
output:
|
||||||
- text: "Here is some "
|
- text: "Here is some "
|
||||||
- a:
|
- a: "link"
|
||||||
- text: "link"
|
|
||||||
attrs:
|
attrs:
|
||||||
href: "https://my.href"
|
href: "https://my.href"
|
||||||
- text: " "
|
- text: " "
|
||||||
|
6
markwon/src/test/resources/tests/single-a.yaml
Normal file
6
markwon/src/test/resources/tests/single-a.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
input: "[link](#href)"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- a: "link"
|
||||||
|
attrs:
|
||||||
|
href: "#href"
|
4
markwon/src/test/resources/tests/single-b.yaml
Normal file
4
markwon/src/test/resources/tests/single-b.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "**bold**"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- b: "bold"
|
4
markwon/src/test/resources/tests/single-blockquote.yaml
Normal file
4
markwon/src/test/resources/tests/single-blockquote.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "> blockquote"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- blockquote: "blockquote"
|
7
markwon/src/test/resources/tests/single-code-block.yaml
Normal file
7
markwon/src/test/resources/tests/single-code-block.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
input: |-
|
||||||
|
```
|
||||||
|
code block
|
||||||
|
```
|
||||||
|
|
||||||
|
output:
|
||||||
|
- code-block: "code block"
|
4
markwon/src/test/resources/tests/single-code.yaml
Normal file
4
markwon/src/test/resources/tests/single-code.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "`code`"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- code: "code"
|
4
markwon/src/test/resources/tests/single-h1.yaml
Normal file
4
markwon/src/test/resources/tests/single-h1.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "# head1"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h1: "head1"
|
4
markwon/src/test/resources/tests/single-h2.yaml
Normal file
4
markwon/src/test/resources/tests/single-h2.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "## head2"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h2: "head2"
|
4
markwon/src/test/resources/tests/single-h3.yaml
Normal file
4
markwon/src/test/resources/tests/single-h3.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "### head3"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h3: "head3"
|
4
markwon/src/test/resources/tests/single-h4.yaml
Normal file
4
markwon/src/test/resources/tests/single-h4.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "#### head4"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h4: "head4"
|
4
markwon/src/test/resources/tests/single-h5.yaml
Normal file
4
markwon/src/test/resources/tests/single-h5.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "##### head5"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h5: "head5"
|
4
markwon/src/test/resources/tests/single-h6.yaml
Normal file
4
markwon/src/test/resources/tests/single-h6.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "###### head6"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- h6: "head6"
|
7
markwon/src/test/resources/tests/single-hr.yaml
Normal file
7
markwon/src/test/resources/tests/single-hr.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# it is failing as we are still removing white spaces manually
|
||||||
|
# this will be fixed when different logic for new lines will be introduced
|
||||||
|
|
||||||
|
input: "---"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- hr: " "
|
4
markwon/src/test/resources/tests/single-i.yaml
Normal file
4
markwon/src/test/resources/tests/single-i.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "*italic*"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- i: "italic"
|
8
markwon/src/test/resources/tests/single-img.yaml
Normal file
8
markwon/src/test/resources/tests/single-img.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
input: ""
|
||||||
|
|
||||||
|
output:
|
||||||
|
- img: "image"
|
||||||
|
attrs:
|
||||||
|
scr: "#href"
|
||||||
|
imageSize: null
|
||||||
|
replacementTextIsLink: false
|
6
markwon/src/test/resources/tests/single-ol.yaml
Normal file
6
markwon/src/test/resources/tests/single-ol.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
input: "1. ol"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- ol: "ol"
|
||||||
|
attrs:
|
||||||
|
start: 1
|
4
markwon/src/test/resources/tests/single-s.yaml
Normal file
4
markwon/src/test/resources/tests/single-s.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "~~strike~~"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- s: "strike"
|
7
markwon/src/test/resources/tests/single-sub.yaml
Normal file
7
markwon/src/test/resources/tests/single-sub.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
input: "<sub>sub</sub>"
|
||||||
|
|
||||||
|
config:
|
||||||
|
use-html: true
|
||||||
|
|
||||||
|
output:
|
||||||
|
- sub: "sub"
|
7
markwon/src/test/resources/tests/single-sup.yaml
Normal file
7
markwon/src/test/resources/tests/single-sup.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
input: "<sup>sup</sup>"
|
||||||
|
|
||||||
|
config:
|
||||||
|
use-html: true
|
||||||
|
|
||||||
|
output:
|
||||||
|
- sup: "sup"
|
7
markwon/src/test/resources/tests/single-task-list.yaml
Normal file
7
markwon/src/test/resources/tests/single-task-list.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
input: "- [ ] task-list"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- task-list: "task-list"
|
||||||
|
attrs:
|
||||||
|
blockIdent: 1
|
||||||
|
done: false
|
4
markwon/src/test/resources/tests/single-tr.yaml
Normal file
4
markwon/src/test/resources/tests/single-tr.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
input: "table-table-table"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- text: "should fail as we are to decide how to pass info here"
|
7
markwon/src/test/resources/tests/single-u.yaml
Normal file
7
markwon/src/test/resources/tests/single-u.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
input: "<u>underline</u>"
|
||||||
|
|
||||||
|
config:
|
||||||
|
use-html: true
|
||||||
|
|
||||||
|
output:
|
||||||
|
- u: "underline"
|
6
markwon/src/test/resources/tests/single-ul.yaml
Normal file
6
markwon/src/test/resources/tests/single-ul.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
input: "* ul"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- ul: "ul"
|
||||||
|
attrs:
|
||||||
|
level: 0
|
Loading…
x
Reference in New Issue
Block a user