Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] test: skipped test in renderer_plugin.test.ts #5123

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 25 additions & 33 deletions tests/renderer_store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,42 +1325,34 @@ describe("renderer", () => {
);

test("Cell overflowing text centered is cut correctly when there's a border", () => {
() => {
const borders = ["right"];
const cellContent = "This is a long text larger than a cell";
const { drawGridRenderer, model, gridRendererStore } = setRenderer(
new Model({
sheets: [
{ id: "sheet1", colNumber: 3, rowNumber: 3, cells: { B2: { content: cellContent } } },
],
})
);
const cellContent = "This is a long text larger than a cell";

setStyle(model, "B2", { align: "center" });
const model = new Model();
resizeColumns(model, ["B"], 10);
setCellContent(model, "B2", cellContent);
setStyle(model, "B2", { align: "center" });
setZoneBorders(model, { position: "right" }, ["B2"]);

for (const border of borders) {
setZoneBorders(model, { position: border as BorderPosition }, ["B2"]);
}

let ctx = new MockGridRenderingContext(model, 1000, 1000, {});
drawGridRenderer(ctx);
const { drawGridRenderer, gridRendererStore } = setRenderer(model);

const box = getBoxFromText(gridRendererStore, cellContent);
const cell = getCell(model, "B2")!;
const textWidth = model.getters.getTextWidth(cell.content, cell.style || {});
const expectedClipRect = model.getters.getVisibleRect({
left: 0,
right: 1,
top: 1,
bottom: 1,
});
const expectedCLipX = box.x + box.width / 2 - textWidth / 2;
expect(box.clipRect).toEqual({
...expectedClipRect,
x: expectedCLipX,
width: expectedClipRect.x + expectedClipRect.width - expectedCLipX,
});
};
let ctx = new MockGridRenderingContext(model, 1000, 1000, {});
drawGridRenderer(ctx);
const box = getBoxFromText(gridRendererStore, cellContent);
const cell = getCell(model, "B2")!;
const textWidth =
model.getters.getTextWidth(cell.content, cell.style || {}) + MIN_CELL_TEXT_MARGIN;
const expectedClipRect = model.getters.getVisibleRect({
left: 0,
right: 1,
top: 1,
bottom: 1,
});
const expectedCLipX = box.x + box.width / 2 - textWidth / 2;
expect(box.clipRect).toEqual({
...expectedClipRect,
x: expectedCLipX,
width: expectedClipRect.x + expectedClipRect.width - expectedCLipX,
});
});

test.each([
Expand Down