diff options
Diffstat (limited to 'tests/document-to-html.tests.js')
| -rw-r--r-- | tests/document-to-html.tests.js | 32 |
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}); |
