From ade2f7706813d785345563c57e7baf902ea2a7f4 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 4 Nov 2017 11:25:51 +0000 Subject: Add style mappings for tables --- tests/conversion_tests.py | 13 +++++++++++ .../styles/parser/document_matcher_parser_tests.py | 25 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index 38aa1a8..a2b1a0b 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -347,6 +347,19 @@ def docx_table_is_converted_to_table_in_html(): assert_equal(expected_html, result.value) +@istest +def table_style_mappings_can_be_used_to_map_tables(): + table = documents.table([], style_name="Normal Table") + result = convert_document_element_to_html( + table, + style_map=[ + _style_mapping("table[style-name='Normal Table'] => table.normal-table:fresh"), + ], + ) + expected_html = '
' + assert_equal(expected_html, result.value) + + @istest def header_rows_are_wrapped_in_thead(): table = documents.table([ diff --git a/tests/styles/parser/document_matcher_parser_tests.py b/tests/styles/parser/document_matcher_parser_tests.py index 62f3181..dc93941 100644 --- a/tests/styles/parser/document_matcher_parser_tests.py +++ b/tests/styles/parser/document_matcher_parser_tests.py @@ -97,6 +97,31 @@ def reads_run_with_style_name(): read_document_matcher("r[style-name='Emphasis']") ) + +@istest +def reads_plain_table(): + assert_equal( + document_matchers.table(), + read_document_matcher("table") + ) + + +@istest +def reads_table_with_style_id(): + assert_equal( + document_matchers.table(style_id="TableNormal"), + read_document_matcher("table.TableNormal") + ) + + +@istest +def reads_table_with_style_name(): + assert_equal( + document_matchers.table(style_name=document_matchers.equal_to("Normal Table")), + read_document_matcher("table[style-name='Normal Table']") + ) + + @istest def reads_bold(): assert_equal( -- cgit v1.2.3