|
1 | 1 | import { Model } from "../../src"; |
2 | | -import { FIGURE_BORDER_WIDTH } from "../../src/constants"; |
3 | 2 | import { buildSheetLink, toZone } from "../../src/helpers"; |
4 | 3 | import { |
5 | 4 | Align, |
@@ -280,8 +279,8 @@ describe("Export data to xlsx then import it", () => { |
280 | 279 | expect(importedFigure.height).toEqual(figure.height); |
281 | 280 | expect(importedFigure.width).toBeBetween(figure.width - 1, figure.width + 1); |
282 | 281 | expect(importedFigure.offset).toEqual({ |
283 | | - x: figure.offset.x + FIGURE_BORDER_WIDTH, |
284 | | - y: figure.offset.y + FIGURE_BORDER_WIDTH, |
| 282 | + x: figure.offset.x, |
| 283 | + y: figure.offset.y, |
285 | 284 | }); |
286 | 285 | }); |
287 | 286 |
|
@@ -401,4 +400,56 @@ describe("Export data to xlsx then import it", () => { |
401 | 400 | expect(newFigure.width).toBe(300); |
402 | 401 | expect(newFigure.height).toBe(400); |
403 | 402 | }); |
| 403 | + |
| 404 | + test.each([ |
| 405 | + { offset: { x: 0, y: 0 }, col: 5, row: 5 }, |
| 406 | + { offset: { x: 10, y: 10 }, col: 10, row: 10 }, |
| 407 | + { offset: { x: 0, y: 10 }, col: 5, row: 0 }, |
| 408 | + { offset: { x: 10, y: 0 }, col: 0, row: 5 }, |
| 409 | + ])("Figure Position", (position) => { |
| 410 | + createImage(model, { |
| 411 | + figureId: "1", |
| 412 | + size: { |
| 413 | + width: 300, |
| 414 | + height: 400, |
| 415 | + }, |
| 416 | + ...position, |
| 417 | + }); |
| 418 | + |
| 419 | + const figure = model.getters.getFigures(sheetId)[0]; |
| 420 | + const importedModel = exportToXlsxThenImport(model); |
| 421 | + const newFigure = importedModel.getters.getFigures(sheetId)[0]; |
| 422 | + expect(newFigure).toMatchObject(figure); |
| 423 | + }); |
| 424 | + |
| 425 | + test.each([ |
| 426 | + { offset: { x: 0, y: 0 }, col: 5, row: 5 }, |
| 427 | + { offset: { x: 10, y: 10 }, col: 10, row: 10 }, |
| 428 | + { offset: { x: 0, y: 10 }, col: 5, row: 0 }, |
| 429 | + { offset: { x: 10, y: 0 }, col: 0, row: 5 }, |
| 430 | + ])("Figure Position with custom row length", (position) => { |
| 431 | + createChart( |
| 432 | + model, |
| 433 | + { |
| 434 | + dataSets: [{ dataRange: "Sheet1!B1:B4" }, { dataRange: "Sheet1!C1:C4" }], |
| 435 | + labelRange: "Sheet1!A2:A4", |
| 436 | + type: "line", |
| 437 | + }, |
| 438 | + "1", |
| 439 | + sheetId, |
| 440 | + { |
| 441 | + figureId: "1", |
| 442 | + size: { |
| 443 | + width: 300, |
| 444 | + height: 400, |
| 445 | + }, |
| 446 | + ...position, |
| 447 | + } |
| 448 | + ); |
| 449 | + resizeRows(model, [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], 100); |
| 450 | + const figure = model.getters.getFigures(sheetId)[0]; |
| 451 | + const importedModel = exportToXlsxThenImport(model); |
| 452 | + const newFigure = importedModel.getters.getFigures(sheetId)[0]; |
| 453 | + expect(newFigure.height).toBe(figure.height); |
| 454 | + }); |
404 | 455 | }); |
0 commit comments