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 { VerticalPositionAlign } from "@file/shared/alignment";
|
2018-10-26 01:04:07 +01:00
|
|
|
|
2021-03-14 17:00:42 +00:00
|
|
|
import { VerticalPositionRelativeFrom } from "./floating-position";
|
2025-04-14 16:43:15 +05:30
|
|
|
import { createVerticalPosition } from "./vertical-position";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
|
|
|
describe("VerticalPosition", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create a element with position align", () => {
|
2019-06-26 22:12:18 +01:00
|
|
|
const tree = new Formatter().format(
|
2025-04-14 16:43:15 +05:30
|
|
|
createVerticalPosition({
|
2018-06-08 16:03:04 +02:00
|
|
|
relative: VerticalPositionRelativeFrom.MARGIN,
|
|
|
|
align: VerticalPositionAlign.INSIDE,
|
|
|
|
}),
|
|
|
|
);
|
2019-06-26 22:12:18 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"wp:positionV": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
relativeFrom: "margin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"wp:align": ["inside"],
|
|
|
|
},
|
|
|
|
],
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should create a element with offset", () => {
|
2019-06-26 22:12:18 +01:00
|
|
|
const tree = new Formatter().format(
|
2025-04-14 16:43:15 +05:30
|
|
|
createVerticalPosition({
|
2018-06-08 16:03:04 +02:00
|
|
|
relative: VerticalPositionRelativeFrom.MARGIN,
|
|
|
|
offset: 40,
|
|
|
|
}),
|
|
|
|
);
|
2019-06-26 22:12:18 +01:00
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"wp:positionV": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
relativeFrom: "margin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"wp:posOffset": ["40"],
|
|
|
|
},
|
|
|
|
],
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|
2021-05-23 08:20:29 +03:00
|
|
|
|
|
|
|
it("should require one of align or offset", () => {
|
2025-04-14 16:43:15 +05:30
|
|
|
expect(() => createVerticalPosition({})).to.throw();
|
2021-05-23 08:20:29 +03:00
|
|
|
});
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
});
|