aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conversion_tests.py8
-rw-r--r--tests/docx/document_xml_tests.py10
-rw-r--r--tests/mammoth_tests.py7
-rwxr-xr-xtests/test-data/strikethrough.docxbin0 -> 12652 bytes
4 files changed, 25 insertions, 0 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
index 19df77f..1563131 100644
--- a/tests/conversion_tests.py
+++ b/tests/conversion_tests.py
@@ -200,6 +200,14 @@ def style_mapping_for_underline_runs_does_not_close_parent_elements():
]
)
assert_equal("<strong><em>Hello</em></strong>", result.value)
+
+
+@istest
+def strikethrough_runs_are_wrapped_in_s_elements_by_default():
+ result = convert_document_element_to_html(
+ documents.run(children=[documents.text("Hello")], is_strikethrough=True),
+ )
+ assert_equal("<s>Hello</s>", result.value)
@istest
diff --git a/tests/docx/document_xml_tests.py b/tests/docx/document_xml_tests.py
index f0fa5ab..bc6fcfb 100644
--- a/tests/docx/document_xml_tests.py
+++ b/tests/docx/document_xml_tests.py
@@ -142,6 +142,16 @@ class ReadXmlElementTests(object):
def run_is_underlined_if_underline_element_is_present(self):
run = self._read_run_with_properties([xml_element("w:u")])
assert_equal(True, run.is_underline)
+
+ @istest
+ def run_is_not_struckthrough_if_strikethrough_element_is_not_present(self):
+ run = self._read_run_with_properties([])
+ assert_equal(False, run.is_strikethrough)
+
+ @istest
+ def run_is_struckthrough_if_strikethrough_element_is_present(self):
+ run = self._read_run_with_properties([xml_element("w:strike")])
+ assert_equal(True, run.is_strikethrough)
@istest
def run_has_baseline_vertical_alignment_if_vertical_alignment_element_is_not_present(self):
diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py
index e7e7e64..84cb6ea 100644
--- a/tests/mammoth_tests.py
+++ b/tests/mammoth_tests.py
@@ -131,6 +131,13 @@ def underline_can_be_configured_with_style_mapping():
@istest
+def strikethrough_is_converted_to_s_element_by_default():
+ with open(test_path("strikethrough.docx"), "rb") as fileobj:
+ result = mammoth.convert_to_html(fileobj=fileobj)
+ assert_equal("<p><s>Today's Special: Salmon</s> Sold out</p>", result.value)
+
+
+@istest
def transform_document_is_applied_to_document_before_conversion():
def transform_document(document):
document.children[0].style_id = "Heading1"
diff --git a/tests/test-data/strikethrough.docx b/tests/test-data/strikethrough.docx
new file mode 100755
index 0000000..0d2b713
--- /dev/null
+++ b/tests/test-data/strikethrough.docx
Binary files differ