Skip to content

Commit

Permalink
Turn regression test for #143 into a snapshot test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhbw committed Feb 23, 2023
1 parent 307067b commit cb22145
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
38 changes: 38 additions & 0 deletions src/__tests__/__snapshots__/templating.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28370,6 +28370,25 @@ Object {
}
`;

exports[`noSandbox Template processing newline character inside variable issue #143 not rendered properly in LibreOffice/GDrive 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
<w:document xmlns:wpc=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\\" xmlns:cx=\\"http:https://schemas.microsoft.com/office/drawing/2014/chartex\\" xmlns:cx1=\\"http:https://schemas.microsoft.com/office/drawing/2015/9/8/chartex\\" xmlns:cx2=\\"http:https://schemas.microsoft.com/office/drawing/2015/10/21/chartex\\" xmlns:cx3=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/9/chartex\\" xmlns:cx4=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/10/chartex\\" xmlns:cx5=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/11/chartex\\" xmlns:cx6=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/12/chartex\\" xmlns:cx7=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/13/chartex\\" xmlns:cx8=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/14/chartex\\" xmlns:mc=\\"http:https://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:aink=\\"http:https://schemas.microsoft.com/office/drawing/2016/ink\\" xmlns:am3d=\\"http:https://schemas.microsoft.com/office/drawing/2017/model3d\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http:https://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:m=\\"http:https://schemas.openxmlformats.org/officeDocument/2006/math\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:wp14=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:wp=\\"http:https://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:w=\\"http:https://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w14=\\"http:https://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http:https://schemas.microsoft.com/office/word/2012/wordml\\" xmlns:w16cex=\\"http:https://schemas.microsoft.com/office/word/2018/wordml/cex\\" xmlns:w16cid=\\"http:https://schemas.microsoft.com/office/word/2016/wordml/cid\\" xmlns:w16=\\"http:https://schemas.microsoft.com/office/word/2018/wordml\\" xmlns:w16se=\\"http:https://schemas.microsoft.com/office/word/2015/wordml/symex\\" xmlns:wpg=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:wpi=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingInk\\" xmlns:wne=\\"http:https://schemas.microsoft.com/office/word/2006/wordml\\" xmlns:wps=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" mc:Ignorable=\\"w14 w15 w16se w16cid w16 w16cex wp14\\">
<w:body>
<w:p w14:paraId=\\"09B4C8A2\\" w14:textId=\\"6B272666\\" w:rsidR=\\"008234FF\\" w:rsidRDefault=\\"00631C10\\">
<w:r>
<w:t xml:space=\\"preserve\\">I am a line</w:t><w:br/><w:t xml:space=\\"preserve\\"></w:t><w:br/><w:t xml:space=\\"preserve\\">And so am I!</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR=\\"008234FF\\" w:rsidSect=\\"00643AF3\\">
<w:pgSz w:w=\\"11900\\" w:h=\\"16840\\"/>
<w:pgMar w:top=\\"1440\\" w:right=\\"1440\\" w:bottom=\\"1440\\" w:left=\\"1440\\" w:header=\\"708\\" w:footer=\\"708\\" w:gutter=\\"0\\"/>
<w:cols w:space=\\"708\\"/>
<w:docGrid w:linePitch=\\"360\\"/>
</w:sectPr>
</w:body>
</w:document>"
`;

exports[`noSandbox Template processing regression test for issue #133 (and #83): LINK inside FOR loop 1`] = `
Object {
"_attrs": Object {
Expand Down Expand Up @@ -58011,6 +58030,25 @@ Object {
}
`;

exports[`sandbox Template processing newline character inside variable issue #143 not rendered properly in LibreOffice/GDrive 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
<w:document xmlns:wpc=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\\" xmlns:cx=\\"http:https://schemas.microsoft.com/office/drawing/2014/chartex\\" xmlns:cx1=\\"http:https://schemas.microsoft.com/office/drawing/2015/9/8/chartex\\" xmlns:cx2=\\"http:https://schemas.microsoft.com/office/drawing/2015/10/21/chartex\\" xmlns:cx3=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/9/chartex\\" xmlns:cx4=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/10/chartex\\" xmlns:cx5=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/11/chartex\\" xmlns:cx6=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/12/chartex\\" xmlns:cx7=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/13/chartex\\" xmlns:cx8=\\"http:https://schemas.microsoft.com/office/drawing/2016/5/14/chartex\\" xmlns:mc=\\"http:https://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:aink=\\"http:https://schemas.microsoft.com/office/drawing/2016/ink\\" xmlns:am3d=\\"http:https://schemas.microsoft.com/office/drawing/2017/model3d\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http:https://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:m=\\"http:https://schemas.openxmlformats.org/officeDocument/2006/math\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:wp14=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:wp=\\"http:https://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:w=\\"http:https://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w14=\\"http:https://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http:https://schemas.microsoft.com/office/word/2012/wordml\\" xmlns:w16cex=\\"http:https://schemas.microsoft.com/office/word/2018/wordml/cex\\" xmlns:w16cid=\\"http:https://schemas.microsoft.com/office/word/2016/wordml/cid\\" xmlns:w16=\\"http:https://schemas.microsoft.com/office/word/2018/wordml\\" xmlns:w16se=\\"http:https://schemas.microsoft.com/office/word/2015/wordml/symex\\" xmlns:wpg=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:wpi=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingInk\\" xmlns:wne=\\"http:https://schemas.microsoft.com/office/word/2006/wordml\\" xmlns:wps=\\"http:https://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" mc:Ignorable=\\"w14 w15 w16se w16cid w16 w16cex wp14\\">
<w:body>
<w:p w14:paraId=\\"09B4C8A2\\" w14:textId=\\"6B272666\\" w:rsidR=\\"008234FF\\" w:rsidRDefault=\\"00631C10\\">
<w:r>
<w:t xml:space=\\"preserve\\">I am a line</w:t><w:br/><w:t xml:space=\\"preserve\\"></w:t><w:br/><w:t xml:space=\\"preserve\\">And so am I!</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR=\\"008234FF\\" w:rsidSect=\\"00643AF3\\">
<w:pgSz w:w=\\"11900\\" w:h=\\"16840\\"/>
<w:pgMar w:top=\\"1440\\" w:right=\\"1440\\" w:bottom=\\"1440\\" w:left=\\"1440\\" w:header=\\"708\\" w:footer=\\"708\\" w:gutter=\\"0\\"/>
<w:cols w:space=\\"708\\"/>
<w:docGrid w:linePitch=\\"360\\"/>
</w:sectPr>
</w:body>
</w:document>"
`;

exports[`sandbox Template processing regression test for issue #133 (and #83): LINK inside FOR loop 1`] = `
Object {
"_attrs": Object {
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/templating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1224,19 +1224,19 @@ Morbi dignissim consequat ex, non finibus est faucibus sodales. Integer sed just
expect(await createReport(opts, 'XML')).toMatchSnapshot();
});

it('newline character inside variable issue #143', async () => {
it('newline character inside variable issue #143 not rendered properly in LibreOffice/GDrive', async () => {
const template = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'newlineInVariableIssue143.docx')
);
const headline = 'I am a line\n\nAnd so am I!';
const result = await createReport({
const opts = {
template,
data: {
headline: headline,
},
});
expect(result).toBeInstanceOf(Uint8Array);
await fs.promises.writeFile('test.docx', result);
processLineBreaksAsNewText: true,
};
expect(await createReport(opts, 'XML')).toMatchSnapshot();
});
});
});
Expand Down

0 comments on commit cb22145

Please sign in to comment.