Skip to content

Commit

Permalink
Added test for .docm support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhbw committed Mar 27, 2021
1 parent 743a552 commit 29af430
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Template-based docx report creation for both Node and the browser. ([See the blo
* Include **literal XML**
* Written in TypeScript, so ships with type definitions.
* Plenty of **examples** in this repo (with Node, Webpack and Browserify)
* Supports `.docm` templates in addition to regular `.docx` files.

Contributions are welcome!

Expand Down
360 changes: 360 additions & 0 deletions src/__tests__/__snapshots__/templating.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28018,6 +28018,186 @@ Object {
}
`;

exports[`noSandbox Template processing works with macro-enabled (docm) templates 1`] = `
Object {
"_attrs": Object {
"mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14",
"xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink",
"xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d",
"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:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
"xmlns:o": "urn:schemas-microsoft-com:office:office",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
"xmlns:v": "urn:schemas-microsoft-com:vml",
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
"xmlns:w10": "urn:schemas-microsoft-com:office:word",
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
"xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml",
"xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml",
"xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex",
"xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid",
"xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex",
"xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
"xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
"xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
"xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
"xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"w14:paraId": "2E1EE055",
"w14:textId": "77777777",
"w:rsidP": "0094382F",
"w:rsidR": "0094382F",
"w:rsidRDefault": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"xml:space": "preserve",
},
"_children": Array [
Object {
"_children": Array [],
"_fTextNode": true,
"_parent": [Circular],
"_text": "4",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:t",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:r",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:p",
},
Object {
"_attrs": Object {
"w14:paraId": "3DCF0DFB",
"w14:textId": "7190F7FD",
"w:rsidP": "0094382F",
"w:rsidR": "0094382F",
"w:rsidRDefault": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"xml:space": "preserve",
},
"_children": Array [
Object {
"_children": Array [],
"_fTextNode": true,
"_parent": [Circular],
"_text": "enigrebua",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:t",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:r",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:p",
},
Object {
"_attrs": Object {
"w:rsidR": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {
"w:h": "16838",
"w:w": "11906",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:pgSz",
},
Object {
"_attrs": Object {
"w:bottom": "1440",
"w:footer": "708",
"w:gutter": "0",
"w:header": "708",
"w:left": "1440",
"w:right": "1440",
"w:top": "1440",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:pgMar",
},
Object {
"_attrs": Object {
"w:space": "708",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:cols",
},
Object {
"_attrs": Object {
"w:linePitch": "360",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:docGrid",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:sectPr",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:body",
},
],
"_fTextNode": false,
"_tag": "w:document",
}
`;

exports[`sandbox Template processing 03 Uses the resolver's response to produce the report 1`] = `
Object {
"_attrs": Object {
Expand Down Expand Up @@ -56035,3 +56215,183 @@ Object {
"_tag": "w:document",
}
`;

exports[`sandbox Template processing works with macro-enabled (docm) templates 1`] = `
Object {
"_attrs": Object {
"mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14",
"xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink",
"xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d",
"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:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
"xmlns:o": "urn:schemas-microsoft-com:office:office",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
"xmlns:v": "urn:schemas-microsoft-com:vml",
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
"xmlns:w10": "urn:schemas-microsoft-com:office:word",
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
"xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml",
"xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml",
"xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex",
"xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid",
"xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex",
"xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
"xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
"xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
"xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
"xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"w14:paraId": "2E1EE055",
"w14:textId": "77777777",
"w:rsidP": "0094382F",
"w:rsidR": "0094382F",
"w:rsidRDefault": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"xml:space": "preserve",
},
"_children": Array [
Object {
"_children": Array [],
"_fTextNode": true,
"_parent": [Circular],
"_text": "4",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:t",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:r",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:p",
},
Object {
"_attrs": Object {
"w14:paraId": "3DCF0DFB",
"w14:textId": "7190F7FD",
"w:rsidP": "0094382F",
"w:rsidR": "0094382F",
"w:rsidRDefault": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {},
"_children": Array [
Object {
"_attrs": Object {
"xml:space": "preserve",
},
"_children": Array [
Object {
"_children": Array [],
"_fTextNode": true,
"_parent": [Circular],
"_text": "enigrebua",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:t",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:r",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:p",
},
Object {
"_attrs": Object {
"w:rsidR": "0094382F",
},
"_children": Array [
Object {
"_attrs": Object {
"w:h": "16838",
"w:w": "11906",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:pgSz",
},
Object {
"_attrs": Object {
"w:bottom": "1440",
"w:footer": "708",
"w:gutter": "0",
"w:header": "708",
"w:left": "1440",
"w:right": "1440",
"w:top": "1440",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:pgMar",
},
Object {
"_attrs": Object {
"w:space": "708",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:cols",
},
Object {
"_attrs": Object {
"w:linePitch": "360",
},
"_children": Array [],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:docGrid",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:sectPr",
},
],
"_fTextNode": false,
"_parent": [Circular],
"_tag": "w:body",
},
],
"_fTextNode": false,
"_tag": "w:document",
}
`;
Binary file added src/__tests__/fixtures/macroEnabledTemplate.docm
Binary file not shown.
Loading

0 comments on commit 29af430

Please sign in to comment.