cleanup getMaxContainerHeight and getMaxContainerWidth and add specs

This commit is contained in:
Aakansha Doshi 2023-02-28 13:31:55 +05:30
parent 7722de4ef2
commit eacee9a158
4 changed files with 87 additions and 52 deletions

View file

@ -17,11 +17,7 @@ import { KEYS } from "../keys";
import { LinearElementEditor } from "../element/linearElementEditor";
import { queryByTestId, queryByText } from "@testing-library/react";
import { resize, rotate } from "./utils";
import {
getBoundTextElementPosition,
wrapText,
getMaxContainerWidth,
} from "../element/textElement";
import { wrapText, getMaxContainerWidth } from "../element/textElement";
import * as textElementUtils from "../element/textElement";
import { ROUNDNESS } from "../constants";
@ -937,8 +933,9 @@ describe("Test Linear Elements", () => {
expect(container.angle).toBe(0);
expect(textElement.angle).toBe(0);
expect(getBoundTextElementPosition(arrow, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(arrow, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 75,
"y": 60,
@ -964,8 +961,9 @@ describe("Test Linear Elements", () => {
rotate(container, -35, 55);
expect(container.angle).toMatchInlineSnapshot(`1.3988061968364685`);
expect(textElement.angle).toBe(0);
expect(getBoundTextElementPosition(container, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(container, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 21.73926141863671,
"y": 73.31003398390868,
@ -1002,8 +1000,9 @@ describe("Test Linear Elements", () => {
);
expect(container.width).toBe(70);
expect(container.height).toBe(50);
expect(getBoundTextElementPosition(container, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(container, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 75,
"y": 60,
@ -1036,8 +1035,9 @@ describe("Test Linear Elements", () => {
}
`);
expect(getBoundTextElementPosition(container, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(container, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 272,
"y": 46,
@ -1070,8 +1070,9 @@ describe("Test Linear Elements", () => {
arrow,
);
expect(container.width).toBe(40);
expect(getBoundTextElementPosition(container, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(container, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 25,
"y": 10,
@ -1095,8 +1096,9 @@ describe("Test Linear Elements", () => {
}
`);
expect(getBoundTextElementPosition(container, textElement))
.toMatchInlineSnapshot(`
expect(
LinearElementEditor.getBoundTextElementPosition(container, textElement),
).toMatchInlineSnapshot(`
Object {
"x": 75,
"y": -4,