@ -3,154 +3,144 @@ import { describe, expect, it } from "vitest";
|
||||
import { Formatter } from "@export/formatter";
|
||||
import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared";
|
||||
|
||||
import { FrameAnchorType, FrameProperties } from "./frame-properties";
|
||||
import { FrameAnchorType, createFrameProperties } from "./frame-properties";
|
||||
|
||||
describe("FrameProperties", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should create", () => {
|
||||
const currentFrameProperties = new FrameProperties({
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
alignment: {
|
||||
x: HorizontalPositionAlign.CENTER,
|
||||
y: VerticalPositionAlign.TOP,
|
||||
},
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:xAlign": "center",
|
||||
"w:y": 3000,
|
||||
"w:yAlign": "top",
|
||||
},
|
||||
},
|
||||
});
|
||||
describe("createFrameProperties", () => {
|
||||
it("should create", () => {
|
||||
const currentFrameProperties = createFrameProperties({
|
||||
type: "absolute",
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
});
|
||||
|
||||
it("should create with the space attribute", () => {
|
||||
const currentFrameProperties = new FrameProperties({
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:y": 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
alignment: {
|
||||
x: HorizontalPositionAlign.CENTER,
|
||||
y: VerticalPositionAlign.TOP,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:xAlign": "center",
|
||||
"w:y": 3000,
|
||||
"w:yAlign": "top",
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
},
|
||||
});
|
||||
it("should create with the space attribute", () => {
|
||||
const currentFrameProperties = createFrameProperties({
|
||||
type: "absolute",
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
|
||||
it("should create without x and y", () => {
|
||||
const currentFrameProperties = new FrameProperties({
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:y": 3000,
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
alignment: {
|
||||
x: HorizontalPositionAlign.CENTER,
|
||||
y: VerticalPositionAlign.TOP,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:xAlign": "center",
|
||||
"w:yAlign": "top",
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
},
|
||||
});
|
||||
it("should create without x and y", () => {
|
||||
const currentFrameProperties = createFrameProperties({
|
||||
type: "alignment",
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
alignment: {
|
||||
x: HorizontalPositionAlign.CENTER,
|
||||
y: VerticalPositionAlign.TOP,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
|
||||
it("should create without alignments", () => {
|
||||
const currentFrameProperties = new FrameProperties({
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:xAlign": "center",
|
||||
"w:yAlign": "top",
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:y": 3000,
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
it("should create without alignments", () => {
|
||||
const currentFrameProperties = createFrameProperties({
|
||||
type: "absolute",
|
||||
position: {
|
||||
x: 1000,
|
||||
y: 3000,
|
||||
},
|
||||
width: 4000,
|
||||
height: 1000,
|
||||
anchor: {
|
||||
horizontal: FrameAnchorType.MARGIN,
|
||||
vertical: FrameAnchorType.MARGIN,
|
||||
},
|
||||
space: {
|
||||
horizontal: 100,
|
||||
vertical: 200,
|
||||
},
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(currentFrameProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:framePr": {
|
||||
_attr: {
|
||||
"w:h": 1000,
|
||||
"w:hAnchor": "margin",
|
||||
"w:vAnchor": "margin",
|
||||
"w:w": 4000,
|
||||
"w:x": 1000,
|
||||
"w:y": 3000,
|
||||
"w:hSpace": 100,
|
||||
"w:vSpace": 200,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user