diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:26:05 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:26:05 +0100 |
| commit | cb18e8aa92108f8576c5d4312e89e6ddbabd88c8 (patch) | |
| tree | 6a0b63f1991c4c1f012164ebb61db15b14fa7f89 /tests | |
| parent | 701f9d8a30a224cb2084b22c743999d133518e7f (diff) | |
Split out test code for generating inline image elements
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/document-xml-reader.tests.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/document-xml-reader.tests.js b/tests/document-xml-reader.tests.js index 3755ec0..96b307d 100644 --- a/tests/document-xml-reader.tests.js +++ b/tests/document-xml-reader.tests.js @@ -100,20 +100,11 @@ describe("readXmlElement: ", function() { }); test("can read inline pictures", function() { - var drawing = new XmlElement("w:drawing", {}, [ - new XmlElement("wp:inline", {}, [ - new XmlElement("wp:docPr", {descr: "It's a hat"}), - new XmlElement("a:graphic", {}, [ - new XmlElement("a:graphicData", {}, [ - new XmlElement("pic:pic", {}, [ - new XmlElement("pic:blipFill", {}, [ - new XmlElement("a:blip", {"r:embed": "rId5"}) - ]) - ]) - ]) - ]) - ]) - ]); + var drawing = createInlineImage({ + relationshipId: "rId5", + description: "It's a hat" + }); + var imageBuffer = new Buffer("Not an image at all!"); var reader = new DocumentXmlReader( @@ -212,3 +203,20 @@ function single(array) { throw new Error("Array has " + array.length + " elements"); } } + +function createInlineImage(options) { + return new XmlElement("w:drawing", {}, [ + new XmlElement("wp:inline", {}, [ + new XmlElement("wp:docPr", {descr: options.description}), + new XmlElement("a:graphic", {}, [ + new XmlElement("a:graphicData", {}, [ + new XmlElement("pic:pic", {}, [ + new XmlElement("pic:blipFill", {}, [ + new XmlElement("a:blip", {"r:embed": options.relationshipId}) + ]) + ]) + ]) + ]) + ]) + ]); +} |
