aboutsummaryrefslogtreecommitdiff
path: root/tests/document-to-html.tests.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-06-17 14:33:43 +0100
committerMichael Williamson <mike@zwobble.org>2015-06-17 14:33:43 +0100
commit17577bdd715c65e71d81f762b54b8c27f60f4535 (patch)
tree5389d7741881b2d198daf450f915fa9b3527f7e7 /tests/document-to-html.tests.js
parentdc31bacddd43e100a2793c76e26d35568262d89a (diff)
Support underlines in style map
Diffstat (limited to 'tests/document-to-html.tests.js')
-rw-r--r--tests/document-to-html.tests.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index 5a271d0..516f2fe 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -177,7 +177,7 @@ describe('DocumentConverter', function() {
});
});
- test('underline runs can be wrapped in <u> tags', function() {
+ test('underline runs can be wrapped in <u> tags using convertUnderline option', function() {
var run = runOfText("Hello.", {isUnderline: true});
var converter = new DocumentConverter({
convertUnderline: mammoth.underline.element("u")
@@ -186,6 +186,36 @@ describe('DocumentConverter', function() {
assert.equal(result.value, "<u>Hello.</u>");
});
});
+
+ test('underline runs can be mapped using style mapping', function() {
+ var run = runOfText("Hello.", {isUnderline: true});
+ var converter = new DocumentConverter({
+ styleMap: [
+ {
+ from: documentMatchers.underline,
+ to: htmlPaths.elements([htmlPaths.element("u")])
+ }
+ ]
+ });
+ return converter.convertToHtml(run).then(function(result) {
+ assert.equal(result.value, "<u>Hello.</u>");
+ });
+ });
+
+ test('style mapping for underline runs does not close parent elements', function() {
+ var run = runOfText("Hello.", {isUnderline: true, isBold: true});
+ var converter = new DocumentConverter({
+ styleMap: [
+ {
+ from: documentMatchers.underline,
+ to: htmlPaths.elements([htmlPaths.element("u")])
+ }
+ ]
+ });
+ return converter.convertToHtml(run).then(function(result) {
+ assert.equal(result.value, "<strong><u>Hello.</u></strong>");
+ });
+ });
test('italic runs are wrapped in <em> tags', function() {
var run = runOfText("Hello.", {isItalic: true});