Fix tests
This commit is contained in:
parent
6c4ffd1778
commit
efa3473cfb
@ -5,6 +5,7 @@
|
||||
* `CoilImagesPlugin` image loader based on [Coil] library (new module: `markwon-image-coil`) ([#166], [#174])
|
||||
<br>Thanks to [@tylerbwong]
|
||||
* `MarkwonInlineParser` to customize inline parsing (new module: `markwon-inline-parser`)
|
||||
* Update commonmark-java to `0.13.0` (and commonmark spec `0.29`)
|
||||
* `Markwon#configuration` method to expose `MarkwonConfiguration` via public API
|
||||
* `HeadingSpan#getLevel` getter
|
||||
* Add `SvgPictureMediaDecoder` in `image` module to deal with SVG without dimensions ([#165])
|
||||
|
@ -7,9 +7,9 @@ Usage of _internal_ classes:
|
||||
```java
|
||||
import org.commonmark.internal.Bracket;
|
||||
import org.commonmark.internal.Delimiter;
|
||||
import org.commonmark.internal.ReferenceParser;
|
||||
import org.commonmark.internal.util.Escaping;
|
||||
import org.commonmark.internal.util.Html5Entities;
|
||||
import org.commonmark.internal.util.LinkScanner;
|
||||
import org.commonmark.internal.util.Parsing;
|
||||
import org.commonmark.internal.inline.AsteriskDelimiterProcessor;
|
||||
import org.commonmark.internal.inline.UnderscoreDelimiterProcessor;
|
||||
@ -20,14 +20,12 @@ import org.commonmark.internal.inline.UnderscoreDelimiterProcessor;
|
||||
```java
|
||||
// all default (like current commonmark-java InlineParserImpl)
|
||||
final InlineParserFactory factory = MarkwonInlineParser.factoryBuilder()
|
||||
.includeDefaults()
|
||||
.build();
|
||||
```
|
||||
|
||||
```java
|
||||
// disable images (current markdown images will be considered as links):
|
||||
final InlineParserFactory factory = MarkwonInlineParser.factoryBuilder()
|
||||
.includeDefaults()
|
||||
.excludeInlineProcessor(BangInlineProcessor.class)
|
||||
.build();
|
||||
```
|
||||
@ -35,7 +33,6 @@ final InlineParserFactory factory = MarkwonInlineParser.factoryBuilder()
|
||||
```java
|
||||
// disable core delimiter processors for `*`|`_` and `**`|`__`
|
||||
final InlineParserFactory factory = MarkwonInlineParser.factoryBuilder()
|
||||
.includeDefaults()
|
||||
.excludeDelimiterProcessor(AsteriskDelimiterProcessor.class)
|
||||
.excludeDelimiterProcessor(UnderscoreDelimiterProcessor.class)
|
||||
.build();
|
||||
@ -43,7 +40,7 @@ final InlineParserFactory factory = MarkwonInlineParser.factoryBuilder()
|
||||
|
||||
```java
|
||||
// disable _all_ markdown inlines except for links (open and close bracket handling `[` & `]`)
|
||||
final InlineParserFactory inlineParserFactory = MarkwonInlineParser.factoryBuilder()
|
||||
final InlineParserFactory inlineParserFactory = MarkwonInlineParser.factoryBuilderNoDefaults()
|
||||
// note that there is no `includeDefaults` method call
|
||||
.referencesEnabled(true)
|
||||
.addInlineProcessor(new OpenBracketInlineProcessor())
|
||||
|
@ -50,6 +50,23 @@ public class OrderedListTest extends BaseSuiteTest {
|
||||
@Test
|
||||
public void two_spaces() {
|
||||
// just a regular flat-list (no sub-lists)
|
||||
// UPD: cannot have more than 3 spaces (0.29), now it is:
|
||||
// 1. First
|
||||
// 2. Second 3. Third
|
||||
|
||||
// final Document document = document(
|
||||
// span(ORDERED_LIST,
|
||||
// args("start", 1),
|
||||
// text("First")),
|
||||
// text("\n"),
|
||||
// span(ORDERED_LIST,
|
||||
// args("start", 2),
|
||||
// text("Second")),
|
||||
// text("\n"),
|
||||
// span(ORDERED_LIST,
|
||||
// args("start", 3),
|
||||
// text("Third"))
|
||||
// );
|
||||
|
||||
final Document document = document(
|
||||
span(ORDERED_LIST,
|
||||
@ -58,11 +75,7 @@ public class OrderedListTest extends BaseSuiteTest {
|
||||
text("\n"),
|
||||
span(ORDERED_LIST,
|
||||
args("start", 2),
|
||||
text("Second")),
|
||||
text("\n"),
|
||||
span(ORDERED_LIST,
|
||||
args("start", 3),
|
||||
text("Third"))
|
||||
text("Second 3. Third"))
|
||||
);
|
||||
|
||||
matchInput("ol-2-spaces.md", document);
|
||||
|
@ -19,6 +19,7 @@ import io.noties.markwon.editor.MarkwonEditor.PreRenderResultListener;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.RETURNS_MOCKS;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
@ -52,6 +53,8 @@ public class MarkwonEditorTextWatcherTest {
|
||||
final ExecutorService service = mock(ExecutorService.class);
|
||||
final EditText editText = mock(EditText.class);
|
||||
|
||||
when(editable.getSpans(anyInt(), anyInt(), any(Class.class))).thenReturn(new Object[0]);
|
||||
|
||||
when(editText.getText()).thenReturn(editable);
|
||||
|
||||
when(service.submit(any(Runnable.class))).thenAnswer(new Answer<Object>() {
|
||||
@ -81,7 +84,7 @@ public class MarkwonEditorTextWatcherTest {
|
||||
ArgumentCaptor.forClass(PreRenderResultListener.class);
|
||||
|
||||
verify(service, times(1)).submit(any(Runnable.class));
|
||||
verify(editor, times(1)).preRender(eq(editable), captor.capture());
|
||||
verify(editor, times(1)).preRender(any(Editable.class), captor.capture());
|
||||
|
||||
final PreRenderResultListener listener = captor.getValue();
|
||||
final PreRenderResult result = mock(PreRenderResult.class);
|
||||
@ -125,7 +128,7 @@ public class MarkwonEditorTextWatcherTest {
|
||||
final MarkwonEditorTextWatcher textWatcher =
|
||||
MarkwonEditorTextWatcher.withPreRender(editor, service, editText);
|
||||
|
||||
textWatcher.afterTextChanged(mock(Editable.class));
|
||||
textWatcher.afterTextChanged(mock(Editable.class, RETURNS_MOCKS));
|
||||
|
||||
verify(editText, times(1)).post(captor.capture());
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user