2018-10-23 09:08:43 -02:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2018-10-26 01:04:07 +01:00
|
|
|
|
2018-10-23 09:08:43 -02:00
|
|
|
import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType, TableFloatProperties } from "./table-float-properties";
|
2019-11-24 03:22:50 +00:00
|
|
|
import { OverlapType } from "./table-overlap";
|
2018-10-23 09:08:43 -02:00
|
|
|
|
|
|
|
describe("Table Float Properties", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should construct a TableFloatProperties with all options", () => {
|
2019-11-24 03:22:50 +00:00
|
|
|
const properties = new TableFloatProperties({
|
2018-10-23 09:08:43 -02:00
|
|
|
horizontalAnchor: TableAnchorType.MARGIN,
|
|
|
|
verticalAnchor: TableAnchorType.PAGE,
|
|
|
|
absoluteHorizontalPosition: 10,
|
|
|
|
relativeHorizontalPosition: RelativeHorizontalPosition.CENTER,
|
|
|
|
absoluteVerticalPosition: 20,
|
|
|
|
relativeVerticalPosition: RelativeVerticalPosition.BOTTOM,
|
|
|
|
bottomFromText: 30,
|
|
|
|
topFromText: 40,
|
|
|
|
leftFromText: 50,
|
|
|
|
rightFromText: 60,
|
|
|
|
});
|
2019-11-24 03:22:50 +00:00
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
expect(tree).to.deep.equal(DEFAULT_TFP);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should add overlap", () => {
|
|
|
|
const properties = new TableFloatProperties({
|
|
|
|
overlap: OverlapType.NEVER,
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:tblpPr": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
overlap: "never",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:tblOverlap": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": "never",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2018-10-23 09:08:43 -02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
const DEFAULT_TFP = {
|
2019-04-09 05:27:18 -04:00
|
|
|
"w:tblpPr": {
|
|
|
|
_attr: {
|
|
|
|
"w:horzAnchor": "margin",
|
|
|
|
"w:vertAnchor": "page",
|
|
|
|
"w:tblpX": 10,
|
|
|
|
"w:tblpXSpec": "center",
|
|
|
|
"w:tblpY": 20,
|
|
|
|
"w:tblpYSpec": "bottom",
|
|
|
|
"w:bottomFromText": 30,
|
|
|
|
"w:topFromText": 40,
|
|
|
|
"w:leftFromText": 50,
|
|
|
|
"w:rightFromText": 60,
|
2018-10-23 09:08:43 -02:00
|
|
|
},
|
2019-04-09 05:27:18 -04:00
|
|
|
},
|
2018-10-23 09:08:43 -02:00
|
|
|
};
|