From 4d4d9e669b389be294373cf3c9bd4727dd5f32af Mon Sep 17 00:00:00 2001 From: Andreas Lubbe Date: Fri, 23 Jan 2015 18:24:23 +0100 Subject: Add support for internal hyperlinks --- tests/document-to-html.tests.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tests/document-to-html.tests.js') 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, 'Hello.'); }); }); - + + test('docx hyperlink with anchor is converted to ', 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, 'Hello.'); + }); + }); + 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("

Hello.

"), 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, 'Hello.'); + }); + }); + + 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) { -- cgit v1.2.3