Files

26 lines
1.0 KiB
Python

from genesis.writer.renderer import render_chapter_blocks
from genesis.writer.models import ChapterContent, ContentBlock
def _content():
blocks = [
ContentBlock(block_id="1", type="heading", level=2, text="小節"),
ContentBlock(block_id="2", type="paragraph", text="正文"),
ContentBlock(block_id="3", type="table", caption="表1", rows=[["a", "b"], ["1", "2"]]),
ContentBlock(block_id="4", type="list", items=["項目一", "項目二"]),
ContentBlock(block_id="5", type="note", text="注意"),
]
return ChapterContent(chapter_id="db_design", version=1, title="DB 設計", blocks=blocks)
def test_render_maps_all_block_types():
out = render_chapter_blocks(_content())
kinds = [b.kind for b in out]
assert kinds == ["heading", "paragraph", "table", "list", "note"]
# 表:rows 透传
table = out[2]
assert table.kind == "table"
assert table.rows == [["a", "b"], ["1", "2"]]
# 列表:items 拼接进 text
assert "項目一" in out[3].text and "項目二" in out[3].text