aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conversion_tests.py19
-rw-r--r--tests/docx/body_xml_tests.py11
-rw-r--r--tests/styles/parser/document_matcher_parser_tests.py7
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py
index 77b0a30..38aa1a8 100644
--- a/tests/conversion_tests.py
+++ b/tests/conversion_tests.py
@@ -228,6 +228,25 @@ def strikethrough_runs_can_be_configured_with_style_mapping():
]
)
assert_equal("<del>Hello</del>", result.value)
+
+
+@istest
+def small_caps_runs_are_ignored_by_default():
+ result = convert_document_element_to_html(
+ documents.run(children=[documents.text("Hello")], is_small_caps=True),
+ )
+ assert_equal("Hello", result.value)
+
+
+@istest
+def small_caps_runs_can_be_mapped_using_style_mapping():
+ result = convert_document_element_to_html(
+ documents.run(children=[documents.text("Hello")], is_small_caps=True),
+ style_map=[
+ _style_mapping("small-caps => span")
+ ]
+ )
+ assert_equal("<span>Hello</span>", result.value)
@istest
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py
index bde96e6..c81fade 100644
--- a/tests/docx/body_xml_tests.py
+++ b/tests/docx/body_xml_tests.py
@@ -213,12 +213,23 @@ class RunTests(object):
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_is_not_small_caps_if_small_caps_element_is_not_present(self):
+ run = self._read_run_with_properties([])
+ assert_equal(False, run.is_small_caps)
+
+ @istest
+ def run_is_small_caps_if_small_caps_element_is_present(self):
+ run = self._read_run_with_properties([xml_element("w:smallCaps")])
+ assert_equal(True, run.is_small_caps)
run_boolean_property_test = lambda func: parameterized([
param(attr_name="is_bold", tag_name="w:b"),
param(attr_name="is_underline", tag_name="w:u"),
param(attr_name="is_italic", tag_name="w:i"),
param(attr_name="is_strikethrough", tag_name="w:strike"),
+ param(attr_name="is_small_caps", tag_name="w:smallCaps"),
])(istest(func))
@run_boolean_property_test
diff --git a/tests/styles/parser/document_matcher_parser_tests.py b/tests/styles/parser/document_matcher_parser_tests.py
index 0286e7b..62f3181 100644
--- a/tests/styles/parser/document_matcher_parser_tests.py
+++ b/tests/styles/parser/document_matcher_parser_tests.py
@@ -126,6 +126,13 @@ def reads_strikethrough():
)
@istest
+def reads_small_caps():
+ assert_equal(
+ document_matchers.small_caps,
+ read_document_matcher("small-caps")
+ )
+
+@istest
def reads_comment_reference():
assert_equal(
document_matchers.comment_reference,