Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
docxtemplater-image-module
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
docxtemplater-image-module
Commits
17fbf596
Commit
17fbf596
authored
Aug 18, 2016
by
Edgar HIPP
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regression test for doc without rId in rels
parent
eca28cc1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
es6/test.js
+25
-0
examples/withoutRels.docx
+0
-0
No files found.
es6/test.js
View file @
17fbf596
...
@@ -17,6 +17,7 @@ const fileNames = [
...
@@ -17,6 +17,7 @@ const fileNames = [
"qrHeader.docx"
,
"qrHeader.docx"
,
"qrHeaderNoImage.docx"
,
"qrHeaderNoImage.docx"
,
"expectedNoImage.docx"
,
"expectedNoImage.docx"
,
"withoutRels.docx"
,
];
];
const
shouldBeSame
=
function
(
zip1
,
zip2
)
{
const
shouldBeSame
=
function
(
zip1
,
zip2
)
{
...
@@ -111,6 +112,30 @@ describe("image adding with {% image} syntax", function () {
...
@@ -111,6 +112,30 @@ describe("image adding with {% image} syntax", function () {
documentFile
.
asText
();
documentFile
.
asText
();
});
});
it
(
"should work without initial rels"
,
function
()
{
const
name
=
"withoutRels.docx"
;
const
imageModule
=
new
ImageModule
(
opts
);
const
doc
=
new
DocxGen
(
docX
[
name
].
loadedContent
);
doc
.
attachModule
(
imageModule
);
const
out
=
loadAndRender
(
doc
,
name
,
{
image
:
"examples/image.png"
});
const
zip
=
out
.
getZip
();
fs
.
writeFile
(
"testWithoutRels.docx"
,
zip
.
generate
({
type
:
"nodebuffer"
}));
const
imageFile
=
zip
.
files
[
"word/media/image_generated_1.png"
];
expect
(
imageFile
!=
null
,
"No image file found"
).
to
.
equal
(
true
);
expect
(
imageFile
.
asText
().
length
).
to
.
be
.
within
(
17417
,
17440
);
const
relsFile
=
zip
.
files
[
"word/_rels/document.xml.rels"
];
expect
(
relsFile
!=
null
,
"No rels file found"
).
to
.
equal
(
true
);
const
relsFileContent
=
relsFile
.
asText
();
expectNormalCharacters
(
relsFileContent
,
'<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Target="numbering.xml" Id="docRId0" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"/> <Relationship Target="styles.xml" Id="docRId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image_generated_1.png"/></Relationships>'
);
const
documentFile
=
zip
.
files
[
"word/document.xml"
];
expect
(
documentFile
!=
null
,
"No document file found"
).
to
.
equal
(
true
);
documentFile
.
asText
();
});
it
(
"should work with image tag == null"
,
function
()
{
it
(
"should work with image tag == null"
,
function
()
{
const
name
=
"imageExample.docx"
;
const
name
=
"imageExample.docx"
;
const
imageModule
=
new
ImageModule
(
opts
);
const
imageModule
=
new
ImageModule
(
opts
);
...
...
examples/withoutRels.docx
0 → 100644
View file @
17fbf596
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment