From 965bd9513da033b9804af8ec29c7fa609a84512c Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 19 Jan 2015 23:05:45 +0000 Subject: Add support for endnotes --- tests/document-to-html.tests.js | 10 ++++++---- tests/docx/document-xml-reader.tests.js | 2 +- tests/mammoth.tests.js | 9 ++++----- tests/test-data/endnotes.docx | Bin 4253 -> 4431 bytes 4 files changed, 11 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index a5cf294..63b445d 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -285,8 +285,9 @@ describe('DocumentConverter', function() { }); test('footnote reference is converted to superscript intra-page link', function() { - var footnoteReference = new documents.FootnoteReference({ - footnoteId: "4" + var footnoteReference = new documents.NoteReference({ + noteType: "footnote", + noteId: "4" }); var converter = new DocumentConverter({ generateUniquifier: function() { return 42; } @@ -297,8 +298,9 @@ describe('DocumentConverter', function() { }); test('footnotes are included after the main body', function() { - var footnoteReference = new documents.FootnoteReference({ - footnoteId: "4" + var footnoteReference = new documents.NoteReference({ + noteType: "footnote", + noteId: "4" }); var document = new documents.Document( [new documents.Paragraph([ diff --git a/tests/docx/document-xml-reader.tests.js b/tests/docx/document-xml-reader.tests.js index 778bf06..86c0fcb 100644 --- a/tests/docx/document-xml-reader.tests.js +++ b/tests/docx/document-xml-reader.tests.js @@ -361,7 +361,7 @@ describe("convertXmlToDocument: ", function() { var documentXml = new XmlElement("w:document", {}, [bodyXml]); var document = convertXmlToDocumentValue({root: documentXml}, {footnotes: footnotes}); - var footnote = document.notes.findFootnoteById("4"); + var footnote = document.notes.resolve({noteType: "footnote", noteId: "4"}); assert.deepEqual(footnote.id, "4"); assert.deepEqual(footnote.body[0].type, "paragraph"); }); diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 08649f4..08eafa4 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -165,17 +165,16 @@ describe('mammoth', function() { }); test('endnotes are appended to text', function() { - return; var docxPath = path.join(__dirname, "test-data/endnotes.docx"); var options = { generateUniquifier: function() { return 42; } }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = '

Ouch' + - '[1].' + - '[2]

' + - '
  1. A tachyon walks into a bar. ↑

  2. ' + - '
  3. Fin. ↑

'; + '[1].' + + '[2]

' + + '
  1. A tachyon walks into a bar. ↑

  2. ' + + '
  3. Fin. ↑

'; assert.equal(result.value, expectedOutput); // TODO: get rid of warnings //~ assert.deepEqual(result.messages, []); diff --git a/tests/test-data/endnotes.docx b/tests/test-data/endnotes.docx index 5ec7faf..1ae4f93 100644 Binary files a/tests/test-data/endnotes.docx and b/tests/test-data/endnotes.docx differ -- cgit v1.2.3