diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/docx/body-reader.tests.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index de7af2d..dee38a5 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -1455,11 +1455,15 @@ function isImage(options) { } } -function readEmbeddedImage(element) { +function readEmbeddedImage(element, options) { + options = options || {}; + + var relationships = [ + imageRelationship("rId5", "media/hat.png") + ].concat(options.relationships || []); + return readXmlElement(element, { - relationships: new Relationships([ - imageRelationship("rId5", "media/hat.png") - ]), + relationships: new Relationships(relationships), contentTypes: fakeContentTypes, docxFile: createFakeDocxFile({ "word/media/hat.png": IMAGE_BUFFER @@ -1642,6 +1646,30 @@ test("no elements created if image cannot be found in wp:inline", function() { assert.deepEqual(result.value, []); }); +test("can read pictures with hyperlink specified in document properties", function() { + var drawing = createInlineImage({ + blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID), + docPrChildren: [ + new XmlElement("a:hlinkClick", {"r:id": "rId42"}) + ] + }); + var relationships = [hyperlinkRelationship("rId42", "http://example.com")]; + + var result = readEmbeddedImage(drawing, {relationships: relationships}); + + return promiseThat(result, isSuccess(contains( + isHyperlink({ + href: "http://example.com", + children: contains( + isImage({ + contentType: "image/png", + buffer: IMAGE_BUFFER + }) + ) + }) + ))); +}); + test("children of w:ins are converted normally", function() { assertChildrenAreConvertedNormally("w:ins"); }); @@ -1893,7 +1921,11 @@ function single(array) { function createInlineImage(options) { return new XmlElement("w:drawing", {}, [ new XmlElement("wp:inline", {}, [ - new XmlElement("wp:docPr", {descr: options.description, title: options.title}), + new XmlElement( + "wp:docPr", + {descr: options.description, title: options.title}, + options.docPrChildren + ), new XmlElement("a:graphic", {}, [ new XmlElement("a:graphicData", {}, [ new XmlElement("pic:pic", {}, [ |
