diff options
Diffstat (limited to 'tests/document-to-html.tests.js')
| -rw-r--r-- | tests/document-to-html.tests.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 3f50cbd..4863cf1 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -239,7 +239,18 @@ describe('DocumentConverter', function() { assert.equal(result.value, '<a href="http://www.example.com">Hello.</a>'); }); }); - + + test('docx hyperlink with anchor is converted to <a>', function() { + var hyperlink = new documents.Hyperlink( + [runOfText("Hello.")], + {anchor: "_Peter"} + ); + var converter = new DocumentConverter(); + return converter.convertToHtml(hyperlink).then(function(result) { + assert.equal(result.value, '<a href="#_Peter">Hello.</a>'); + }); + }); + test('docx tab is converted to tab in HTML', function() { var tab = new documents.Tab(); var converter = new DocumentConverter(); @@ -405,6 +416,27 @@ describe('DocumentConverter', function() { assert.equal(result.value.indexOf("<p>Hello.</p>"), 0); }); }); + + test('referenced bookmarks are coverted to anchors', function() { + var bookmarkStart = new documents.BookmarkStart({name: "_Peter"}); + var hyperlink = new documents.Hyperlink( + [runOfText("Hello.")], + {anchor: "_Peter"} + ); + var converter = new DocumentConverter(); + var document = new documents.Document([bookmarkStart, hyperlink]); + return converter.convertToHtml(document).then(function(result) { + assert.equal(result.value, '<span id="_Peter"></span><a href="#_Peter">Hello.</a>'); + }); + }); + + test('unreferenced bookmarks are not converted', function() { + var bookmarkStart = new documents.BookmarkStart({name: "_Unreferenced"}); + var converter = new DocumentConverter(); + return converter.convertToHtml(bookmarkStart).then(function(result) { + assert.equal(result.value, ''); + }); + }); }); function paragraphOfText(text, styleId, styleName) { |
