From 0a3b5dca1fd022f0071f0fd9895e3680a23bee7a Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 26 Aug 2021 21:02:09 +0200 Subject: start working on more tests --- tests/test_document.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_document.py (limited to 'tests/test_document.py') diff --git a/tests/test_document.py b/tests/test_document.py new file mode 100644 index 0000000..35f706f --- /dev/null +++ b/tests/test_document.py @@ -0,0 +1,50 @@ +from wikimini import document + + +class TestBlockLink: + + def test_append(self): + link = document.BlockLink("https://localhost", "foo ") + link.append(document.Plain("bar")) + assert link.title == "foo bar" + + link.append(document.Style(document.Plain("qux"), False, True, False)) + assert link.title == "foo barqux" + + def test_plain(self): + link = document.BlockLink("https://localhost", "foo ") + assert link.plain() == "foo " + + def test_to_nodes(self): + link = document.BlockLink("https://localhost", "foo ") + assert link.to_nodes() == [ + document.Plain("foo ") + ] + + +class TestBlockQuote: + + def test_append(self): + quote = document.BlockQuote(document.Paragraph([])) + quote.append(document.Plain("Foo")) + assert quote.plain() == "Foo" + assert len(quote.content.nodes) == 1 + + quote.append(document.Style(document.Plain("bar"), True, True, False)) + assert quote.plain() == "Foobar" + assert len(quote.content.nodes) == 2 + + def test_plain(self): + quote = document.BlockQuote(document.Paragraph([ + document.Plain("Foo"), + document.InlineLink("http://localhost", document.Plain("bar")), + ])) + assert quote.plain() == "Foobar" + + def test_to_nodes(self): + nodes = [ + document.Plain("Foo"), + document.InlineLink("http://localhost", document.Plain("bar")), + ] + assert (document.BlockQuote(document.Paragraph(nodes)).to_nodes() + == nodes) -- cgit v1.2.3