Skip to content

Commit

Permalink
Added snapshot test for behaviour described in PR #233.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhbw committed Sep 28, 2021
1 parent 7c6142b commit 292b48d
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
182 changes: 182 additions & 0 deletions src/__tests__/__snapshots__/templating.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26644,6 +26644,97 @@ Object {
}
`;

exports[`noSandbox Template processing HTML in table (see PR #233) 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
<w:document xmlns:wpc=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\\" xmlns:cx=\\"http://schemas.microsoft.com/office/drawing/2014/chartex\\" xmlns:cx1=\\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\\" xmlns:cx2=\\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\\" xmlns:cx3=\\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\\" xmlns:cx4=\\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\\" xmlns:cx5=\\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\\" xmlns:cx6=\\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\\" xmlns:cx7=\\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\\" xmlns:cx8=\\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:aink=\\"http://schemas.microsoft.com/office/drawing/2016/ink\\" xmlns:am3d=\\"http://schemas.microsoft.com/office/drawing/2017/model3d\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:m=\\"http://schemas.openxmlformats.org/officeDocument/2006/math\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" xmlns:w16cex=\\"http://schemas.microsoft.com/office/word/2018/wordml/cex\\" xmlns:w16cid=\\"http://schemas.microsoft.com/office/word/2016/wordml/cid\\" xmlns:w16=\\"http://schemas.microsoft.com/office/word/2018/wordml\\" xmlns:w16sdtdh=\\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\\" xmlns:w16se=\\"http://schemas.microsoft.com/office/word/2015/wordml/symex\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:wpi=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\\" xmlns:wne=\\"http://schemas.microsoft.com/office/word/2006/wordml\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" mc:Ignorable=\\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\\">
<w:body>
<w:tbl>
<w:tblPr>
<w:tblStyle w:val=\\"TableGrid\\"/>
<w:tblW w:w=\\"0\\" w:type=\\"auto\\"/>
<w:tblLook w:val=\\"04A0\\" w:firstRow=\\"1\\" w:lastRow=\\"0\\" w:firstColumn=\\"1\\" w:lastColumn=\\"0\\" w:noHBand=\\"0\\" w:noVBand=\\"1\\"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w=\\"4508\\"/>
<w:gridCol w:w=\\"4508\\"/>
</w:tblGrid>
<w:tr w:rsidR=\\"008B7E2D\\" w14:paraId=\\"0178839F\\" w14:textId=\\"77777777\\" w:rsidTr=\\"008B7E2D\\">
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"055E6634\\" w14:textId=\\"1FCEF5A5\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">First Name</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:altChunk r:id=\\"html1\\"/>
<w:p/>
</w:tc>
</w:tr>
<w:tr w:rsidR=\\"008B7E2D\\" w14:paraId=\\"57653FD2\\" w14:textId=\\"77777777\\" w:rsidTr=\\"008B7E2D\\">
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"075E2775\\" w14:textId=\\"7E2FEF1D\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">Last Name</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"421C6BED\\" w14:textId=\\"73041DE5\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">Smith</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p w14:paraId=\\"5F7D8AD4\\" w14:textId=\\"77777777\\" w:rsidR=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\"/>
<w:sectPr w:rsidR=\\"008B7E2D\\">
<w:pgSz w:w=\\"11906\\" w:h=\\"16838\\"/>
<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 INS command is an array (see issue #214) 1`] = `
Object {
"_attrs": Object {
Expand Down Expand Up @@ -55780,6 +55871,97 @@ Object {
}
`;

exports[`sandbox Template processing HTML in table (see PR #233) 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
<w:document xmlns:wpc=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\\" xmlns:cx=\\"http://schemas.microsoft.com/office/drawing/2014/chartex\\" xmlns:cx1=\\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\\" xmlns:cx2=\\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\\" xmlns:cx3=\\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\\" xmlns:cx4=\\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\\" xmlns:cx5=\\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\\" xmlns:cx6=\\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\\" xmlns:cx7=\\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\\" xmlns:cx8=\\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\\" xmlns:mc=\\"http://schemas.openxmlformats.org/markup-compatibility/2006\\" xmlns:aink=\\"http://schemas.microsoft.com/office/drawing/2016/ink\\" xmlns:am3d=\\"http://schemas.microsoft.com/office/drawing/2017/model3d\\" xmlns:o=\\"urn:schemas-microsoft-com:office:office\\" xmlns:r=\\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\\" xmlns:m=\\"http://schemas.openxmlformats.org/officeDocument/2006/math\\" xmlns:v=\\"urn:schemas-microsoft-com:vml\\" xmlns:wp14=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\\" xmlns:wp=\\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\\" xmlns:w10=\\"urn:schemas-microsoft-com:office:word\\" xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\" xmlns:w14=\\"http://schemas.microsoft.com/office/word/2010/wordml\\" xmlns:w15=\\"http://schemas.microsoft.com/office/word/2012/wordml\\" xmlns:w16cex=\\"http://schemas.microsoft.com/office/word/2018/wordml/cex\\" xmlns:w16cid=\\"http://schemas.microsoft.com/office/word/2016/wordml/cid\\" xmlns:w16=\\"http://schemas.microsoft.com/office/word/2018/wordml\\" xmlns:w16sdtdh=\\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\\" xmlns:w16se=\\"http://schemas.microsoft.com/office/word/2015/wordml/symex\\" xmlns:wpg=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\\" xmlns:wpi=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\\" xmlns:wne=\\"http://schemas.microsoft.com/office/word/2006/wordml\\" xmlns:wps=\\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\\" mc:Ignorable=\\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\\">
<w:body>
<w:tbl>
<w:tblPr>
<w:tblStyle w:val=\\"TableGrid\\"/>
<w:tblW w:w=\\"0\\" w:type=\\"auto\\"/>
<w:tblLook w:val=\\"04A0\\" w:firstRow=\\"1\\" w:lastRow=\\"0\\" w:firstColumn=\\"1\\" w:lastColumn=\\"0\\" w:noHBand=\\"0\\" w:noVBand=\\"1\\"/>
</w:tblPr>
<w:tblGrid>
<w:gridCol w:w=\\"4508\\"/>
<w:gridCol w:w=\\"4508\\"/>
</w:tblGrid>
<w:tr w:rsidR=\\"008B7E2D\\" w14:paraId=\\"0178839F\\" w14:textId=\\"77777777\\" w:rsidTr=\\"008B7E2D\\">
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"055E6634\\" w14:textId=\\"1FCEF5A5\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">First Name</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:altChunk r:id=\\"html1\\"/>
<w:p/>
</w:tc>
</w:tr>
<w:tr w:rsidR=\\"008B7E2D\\" w14:paraId=\\"57653FD2\\" w14:textId=\\"77777777\\" w:rsidTr=\\"008B7E2D\\">
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"075E2775\\" w14:textId=\\"7E2FEF1D\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">Last Name</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w=\\"4508\\" w:type=\\"dxa\\"/>
</w:tcPr>
<w:p w14:paraId=\\"421C6BED\\" w14:textId=\\"73041DE5\\" w:rsidR=\\"008B7E2D\\" w:rsidRPr=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\">
<w:pPr>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:lang w:val=\\"nl-NL\\"/>
</w:rPr>
<w:t xml:space=\\"preserve\\">Smith</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
</w:tbl>
<w:p w14:paraId=\\"5F7D8AD4\\" w14:textId=\\"77777777\\" w:rsidR=\\"008B7E2D\\" w:rsidRDefault=\\"008B7E2D\\"/>
<w:sectPr w:rsidR=\\"008B7E2D\\">
<w:pgSz w:w=\\"11906\\" w:h=\\"16838\\"/>
<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 INS command is an array (see issue #214) 1`] = `
Object {
"_attrs": Object {
Expand Down
Binary file added src/__tests__/fixtures/tableWithHTML.docx
Binary file not shown.
16 changes: 16 additions & 0 deletions src/__tests__/templating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,22 @@ Morbi dignissim consequat ex, non finibus est faucibus sodales. Integer sed just
)
).toMatchSnapshot();
});

it('HTML in table (see PR #233)', async () => {
const template = await fs.promises.readFile(
path.join(__dirname, 'fixtures', 'tableWithHTML.docx')
);
expect(
await createReport(
{
noSandbox,
template,
data: {},
},
'XML'
)
).toMatchSnapshot();
});
});
});
});

0 comments on commit 292b48d

Please sign in to comment.