diff options
| author | Andreas Lubbe <git@lubbe.org> | 2015-01-23 18:24:23 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-09 20:31:51 +0000 |
| commit | 4d4d9e669b389be294373cf3c9bd4727dd5f32af (patch) | |
| tree | d66a47574dfea6c24328aa296cb3b67f2d7890f2 /tests/document-to-html.tests.js | |
| parent | 37cdbc47dc105a3c745e0f718843e68cf1741aed (diff) | |
Add support for internal hyperlinks
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) { |
