2018-06-21 12:03:34 +02:00
|
|
|
import { expect } from "chai";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
2018-10-26 01:04:07 +01:00
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
|
2018-06-21 12:03:34 +02:00
|
|
|
import { Body } from "./body";
|
2021-05-25 03:41:12 +03:00
|
|
|
import { sectionMarginDefaults } from "./section-properties";
|
2016-03-31 23:01:20 +01:00
|
|
|
|
2016-04-03 05:24:56 +01:00
|
|
|
describe("Body", () => {
|
2018-06-21 12:03:34 +02:00
|
|
|
let body: Body;
|
2016-03-31 23:01:20 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2018-06-21 12:03:34 +02:00
|
|
|
body = new Body();
|
2016-03-31 23:01:20 +01:00
|
|
|
});
|
|
|
|
|
2018-11-01 02:22:32 +00:00
|
|
|
describe("#addSection", () => {
|
|
|
|
it("should add section with default parameters", () => {
|
|
|
|
body.addSection({
|
2021-03-19 20:53:56 +00:00
|
|
|
page: {
|
|
|
|
size: {
|
|
|
|
width: 10000,
|
|
|
|
height: 10000,
|
|
|
|
},
|
|
|
|
},
|
2018-11-01 02:22:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const tree = new Formatter().format(body);
|
|
|
|
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:body": [
|
|
|
|
{
|
|
|
|
"w:sectPr": [
|
2019-04-09 05:27:18 -04:00
|
|
|
{ "w:pgSz": { _attr: { "w:w": 10000, "w:h": 10000, "w:orient": "portrait" } } },
|
2018-11-01 02:22:32 +00:00
|
|
|
{
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:pgMar": {
|
|
|
|
_attr: {
|
2021-05-25 03:41:12 +03:00
|
|
|
"w:top": sectionMarginDefaults.TOP,
|
|
|
|
"w:right": sectionMarginDefaults.RIGHT,
|
|
|
|
"w:bottom": sectionMarginDefaults.BOTTOM,
|
|
|
|
"w:left": sectionMarginDefaults.LEFT,
|
|
|
|
"w:header": sectionMarginDefaults.HEADER,
|
|
|
|
"w:footer": sectionMarginDefaults.FOOTER,
|
|
|
|
"w:gutter": sectionMarginDefaults.GUTTER,
|
2018-11-01 02:22:32 +00:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-11-01 02:22:32 +00:00
|
|
|
},
|
2021-03-09 22:37:37 +00:00
|
|
|
{
|
|
|
|
"w:pgNumType": {
|
|
|
|
_attr: {},
|
|
|
|
},
|
|
|
|
},
|
2021-05-25 03:41:12 +03:00
|
|
|
// { "w:cols": { _attr: { "w:space": 708, "w:sep": false, "w:num": 1 } } },
|
2021-05-20 02:18:17 +03:00
|
|
|
{ "w:docGrid": { _attr: { "w:linePitch": 360 } } },
|
2018-11-01 02:22:32 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-03-09 22:31:55 +00:00
|
|
|
});
|