2023-06-05 00:33:43 +01:00
|
|
|
import { describe, expect, it } from "vitest";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
|
|
|
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";
|
2025-04-14 16:43:15 +05:30
|
|
|
import { createHorizontalPosition } 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(
|
2025-04-14 16:43:15 +05:30
|
|
|
createHorizontalPosition({
|
2018-06-08 16:03:04 +02:00
|
|
|
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(
|
2025-04-14 16:43:15 +05:30
|
|
|
createHorizontalPosition({
|
2018-06-08 16:03:04 +02:00
|
|
|
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", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
expect(() => createHorizontalPosition({})).to.throw();
|
2021-05-24 09:25:52 +03:00
|
|
|
});
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|