Skip to content

Commit fe1428d

Browse files
committed
content test: Test parsing lists
1 parent 4f9b54d commit fe1428d

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/model/content_test.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,48 @@ void main() {
194194
]);
195195
});
196196

197+
group('parse lists', () {
198+
testParse('<ol>',
199+
// "1. first\n2. then"
200+
'<ol>\n<li>first</li>\n<li>then</li>\n</ol>', const [
201+
ListNode(ListStyle.ordered, [
202+
[ParagraphNode(wasImplicit: true, nodes: [TextNode('first')])],
203+
[ParagraphNode(wasImplicit: true, nodes: [TextNode('then')])],
204+
]),
205+
]);
206+
207+
testParse('<ul>',
208+
// "* something\n* another"
209+
'<ul>\n<li>something</li>\n<li>another</li>\n</ul>', const [
210+
ListNode(ListStyle.unordered, [
211+
[ParagraphNode(wasImplicit: true, nodes: [TextNode('something')])],
212+
[ParagraphNode(wasImplicit: true, nodes: [TextNode('another')])],
213+
]),
214+
]);
215+
216+
testParse('implicit paragraph with internal <br>',
217+
// "* a\n b"
218+
'<ul>\n<li>a<br>\n b</li>\n</ul>', const [
219+
ListNode(ListStyle.unordered, [
220+
[ParagraphNode(wasImplicit: true, nodes: [
221+
TextNode('a'),
222+
LineBreakInlineNode(),
223+
TextNode('\n b'), // TODO: this renders misaligned
224+
])],
225+
])
226+
]);
227+
228+
testParse('explicit paragraphs',
229+
// "* a\n\n b"
230+
'<ul>\n<li>\n<p>a</p>\n<p>b</p>\n</li>\n</ul>', const [
231+
ListNode(ListStyle.unordered, [
232+
[
233+
ParagraphNode(nodes: [TextNode('a')]),
234+
ParagraphNode(nodes: [TextNode('b')]),
235+
],
236+
]),
237+
]);
238+
});
239+
197240
// TODO write more tests for this code
198241
}

0 commit comments

Comments
 (0)