2019-06-27 01:35:58 +01:00
|
|
|
import { expect } from "chai";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2019-06-27 01:35:58 +01:00
|
|
|
import { Formatter } from "export/formatter";
|
2021-03-14 17:00:42 +00:00
|
|
|
import { HorizontalPositionAlign } from "file/shared/alignment";
|
2018-10-26 01:04:07 +01:00
|
|
|
|
2021-03-14 17:00:42 +00:00
|
|
|
import { HorizontalPositionRelativeFrom } from "./floating-position";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { HorizontalPosition } from "./horizontal-position";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
|
|
|
describe("HorizontalPosition", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create a element with position align", () => {
|
2019-06-27 01:35:58 +01:00
|
|
|
const tree = new Formatter().format(
|
2018-06-08 16:03:04 +02:00
|
|
|
new HorizontalPosition({
|
|
|
|
relative: HorizontalPositionRelativeFrom.MARGIN,
|
|
|
|
align: HorizontalPositionAlign.CENTER,
|
|
|
|
}),
|
|
|
|
);
|
2019-06-27 01:35:58 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"wp:positionH": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
relativeFrom: "margin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"wp:align": ["center"],
|
|
|
|
},
|
|
|
|
],
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should create a element with offset", () => {
|
2019-06-27 01:35:58 +01:00
|
|
|
const tree = new Formatter().format(
|
2018-06-08 16:03:04 +02:00
|
|
|
new HorizontalPosition({
|
|
|
|
relative: HorizontalPositionRelativeFrom.MARGIN,
|
|
|
|
offset: 40,
|
|
|
|
}),
|
|
|
|
);
|
2019-06-27 01:35:58 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"wp:positionH": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
relativeFrom: "margin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"wp:posOffset": ["40"],
|
|
|
|
},
|
|
|
|
],
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|
2021-05-24 09:25:52 +03:00
|
|
|
|
|
|
|
it("should require one of align or offset", () => {
|
|
|
|
expect(() => new HorizontalPosition({})).to.throw();
|
|
|
|
});
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|