diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-01-25 17:17:34 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-01-25 17:17:34 +0000 |
| commit | 52c4d01e4a0e35738e8c1db35a5a4a7ab981803d (patch) | |
| tree | 0cce833e77942311d25a7c92828d7f5802be14b5 /tests | |
| parent | 2de4641bed73f04d0c1ac345e132c1a79fc48f14 (diff) | |
Use prefix to generate IDs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/document-to-html.tests.js | 12 | ||||
| -rw-r--r-- | tests/docx/document-xml-reader.tests.js | 2 | ||||
| -rw-r--r-- | tests/mammoth.tests.js | 20 |
3 files changed, 17 insertions, 17 deletions
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 63b445d..17fdb27 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -290,10 +290,10 @@ describe('DocumentConverter', function() { noteId: "4" }); var converter = new DocumentConverter({ - generateUniquifier: function() { return 42; } + idPrefix: "doc-42" }); return converter.convertToHtml(footnoteReference).then(function(result) { - assert.equal(result.value, '<sup><a href="#footnote-42-4" id="footnote-ref-42-4">[1]</a></sup>'); + assert.equal(result.value, '<sup><a href="#doc-42-footnote-4" id="doc-42-footnote-ref-4">[1]</a></sup>'); }); }); @@ -311,7 +311,7 @@ describe('DocumentConverter', function() { notes: new documents.Notes({ 4: new documents.Note({ noteType: "footnote", - id: "4", + noteId: "4", body: [paragraphOfText("Who's there?")] }) }) @@ -319,11 +319,11 @@ describe('DocumentConverter', function() { ); var converter = new DocumentConverter({ - generateUniquifier: function() { return 42; } + idPrefix: "doc-42" }); return converter.convertToHtml(document).then(function(result) { - var expectedOutput = '<p>Knock knock<sup><a href="#footnote-42-4" id="footnote-ref-42-4">[1]</a></sup></p>' + - '<ol><li id="footnote-42-4"><p>Who\'s there? <a href="#footnote-ref-42-4">↑</a></p></li></ol>'; + var expectedOutput = '<p>Knock knock<sup><a href="#doc-42-footnote-4" id="doc-42-footnote-ref-4">[1]</a></sup></p>' + + '<ol><li id="doc-42-footnote-4"><p>Who\'s there? <a href="#doc-42-footnote-ref-4">↑</a></p></li></ol>'; assert.equal(result.value, expectedOutput); }); }); diff --git a/tests/docx/document-xml-reader.tests.js b/tests/docx/document-xml-reader.tests.js index 86c0fcb..3350917 100644 --- a/tests/docx/document-xml-reader.tests.js +++ b/tests/docx/document-xml-reader.tests.js @@ -362,7 +362,7 @@ describe("convertXmlToDocument: ", function() { var document = convertXmlToDocumentValue({root: documentXml}, {footnotes: footnotes}); var footnote = document.notes.resolve({noteType: "footnote", noteId: "4"}); - assert.deepEqual(footnote.id, "4"); + assert.deepEqual(footnote.noteId, "4"); assert.deepEqual(footnote.body[0].type, "paragraph"); }); }); diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 48ce680..985dd99 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -150,14 +150,14 @@ describe('mammoth', function() { // TODO: don't duplicate footnotes with multiple references var docxPath = path.join(__dirname, "test-data/footnotes.docx"); var options = { - generateUniquifier: function() { return 42; } + idPrefix: "doc-42" }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = '<p>Ouch' + - '<sup><a href="#footnote-42-1" id="footnote-ref-42-1">[1]</a></sup>.' + - '<sup><a href="#footnote-42-2" id="footnote-ref-42-2">[2]</a></sup></p>' + - '<ol><li id="footnote-42-1"><p> A tachyon walks into a bar. <a href="#footnote-ref-42-1">↑</a></p></li>' + - '<li id="footnote-42-2"><p> Fin. <a href="#footnote-ref-42-2">↑</a></p></li></ol>'; + '<sup><a href="#doc-42-footnote-1" id="doc-42-footnote-ref-1">[1]</a></sup>.' + + '<sup><a href="#doc-42-footnote-2" id="doc-42-footnote-ref-2">[2]</a></sup></p>' + + '<ol><li id="doc-42-footnote-1"><p> A tachyon walks into a bar. <a href="#doc-42-footnote-ref-1">↑</a></p></li>' + + '<li id="doc-42-footnote-2"><p> Fin. <a href="#doc-42-footnote-ref-2">↑</a></p></li></ol>'; assert.equal(result.value, expectedOutput); assert.deepEqual(result.messages, []); }); @@ -166,14 +166,14 @@ describe('mammoth', function() { test('endnotes are appended to text', function() { var docxPath = path.join(__dirname, "test-data/endnotes.docx"); var options = { - generateUniquifier: function() { return 42; } + idPrefix: "doc-42" }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = '<p>Ouch' + - '<sup><a href="#endnote-42-2" id="endnote-ref-42-2">[1]</a></sup>.' + - '<sup><a href="#endnote-42-3" id="endnote-ref-42-3">[2]</a></sup></p>' + - '<ol><li id="endnote-42-2"><p> A tachyon walks into a bar. <a href="#endnote-ref-42-2">↑</a></p></li>' + - '<li id="endnote-42-3"><p> Fin. <a href="#endnote-ref-42-3">↑</a></p></li></ol>'; + '<sup><a href="#doc-42-endnote-2" id="doc-42-endnote-ref-2">[1]</a></sup>.' + + '<sup><a href="#doc-42-endnote-3" id="doc-42-endnote-ref-3">[2]</a></sup></p>' + + '<ol><li id="doc-42-endnote-2"><p> A tachyon walks into a bar. <a href="#doc-42-endnote-ref-2">↑</a></p></li>' + + '<li id="doc-42-endnote-3"><p> Fin. <a href="#doc-42-endnote-ref-3">↑</a></p></li></ol>'; assert.equal(result.value, expectedOutput); assert.deepEqual(result.messages, []); }); |
