Better assertions for nested blocks
This commit is contained in:
parent
97c994d866
commit
a0e208c370
@ -72,7 +72,7 @@ public class SpannableMarkdownVisitorTest {
|
|||||||
assertEquals(stringBuilder.length(), index);
|
assertEquals(stringBuilder.length(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int validate(@NonNull SpannableStringBuilder builder, int index, @NonNull TestNode node) {
|
private int validate(@NonNull final SpannableStringBuilder builder, final int index, @NonNull TestNode node) {
|
||||||
|
|
||||||
if (node.isText()) {
|
if (node.isText()) {
|
||||||
|
|
||||||
@ -109,6 +109,8 @@ public class SpannableMarkdownVisitorTest {
|
|||||||
out = validate(builder, out, child);
|
out = validate(builder, out, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int end = out;
|
||||||
|
|
||||||
final String info = node.toString();
|
final String info = node.toString();
|
||||||
|
|
||||||
System.out.printf("%s: %s%n", file, builder.subSequence(index, out));
|
System.out.printf("%s: %s%n", file, builder.subSequence(index, out));
|
||||||
@ -128,7 +130,9 @@ public class SpannableMarkdownVisitorTest {
|
|||||||
.filter(new IxPredicate<TestSpan>() {
|
.filter(new IxPredicate<TestSpan>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean test(TestSpan testSpan) {
|
public boolean test(TestSpan testSpan) {
|
||||||
return span.name().equals(testSpan.name());
|
return span.name().equals(testSpan.name())
|
||||||
|
&& index == builder.getSpanStart(testSpan)
|
||||||
|
&& end == builder.getSpanEnd(testSpan);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.first(null);
|
.first(null);
|
||||||
@ -139,6 +143,11 @@ public class SpannableMarkdownVisitorTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(info, span.name(), testSpan.name());
|
assertEquals(info, span.name(), testSpan.name());
|
||||||
|
|
||||||
|
// for correct tracking of nested blocks we must validate expected start/end
|
||||||
|
assertEquals(info, index, builder.getSpanStart(testSpan));
|
||||||
|
assertEquals(info, out, builder.getSpanEnd(testSpan));
|
||||||
|
|
||||||
assertMapEquals(info, span.attributes(), testSpan.attributes());
|
assertMapEquals(info, span.attributes(), testSpan.attributes());
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
12
markwon/src/test/resources/tests/nested-blockquotes.yaml
Normal file
12
markwon/src/test/resources/tests/nested-blockquotes.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
input: |-
|
||||||
|
> First
|
||||||
|
> > Second
|
||||||
|
> > > Third
|
||||||
|
|
||||||
|
output:
|
||||||
|
- blockquote:
|
||||||
|
- text: "First\n\n"
|
||||||
|
- blockquote:
|
||||||
|
- text: "Second\n\n"
|
||||||
|
- blockquote:
|
||||||
|
- text: "Third"
|
@ -21,8 +21,8 @@ output:
|
|||||||
- text: " "
|
- text: " "
|
||||||
- s: "strike"
|
- s: "strike"
|
||||||
- text: " down\n\n"
|
- text: " down\n\n"
|
||||||
- blockquote: "Some quote here!"
|
- blockquote: "Some quote here!\n"
|
||||||
- text: "\n\n"
|
- text: "\n"
|
||||||
- h1: "Header 1"
|
- h1: "Header 1"
|
||||||
- text: "\n\n"
|
- text: "\n\n"
|
||||||
- h2: "Header 2"
|
- h2: "Header 2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user