1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

Spreadsheet: Add Range(s).toArray()

This commit is contained in:
u9g 2022-03-02 18:30:14 -05:00 committed by Ali Mohammad Pur
parent 6302ca0043
commit 93115ee044
3 changed files with 40 additions and 9 deletions

View file

@ -114,11 +114,34 @@ describe("Range", () => {
const sheet = createSheet(workbook, "Sheet 1");
sheet.makeCurrent();
let i = 0;
for (const col of ["A", "B"])
for (const row of [0, 1, 2]) sheet.setCell(col, row, Math.pow(i++, 2));
for (const col of ["A", "B"]) {
for (const row of [0, 1, 2]) {
sheet.setCell(col, row, Math.pow(i++, 2));
}
}
sheet.focusCell("A", 0);
expect(R`A0:A2`.at(2).name).toEqual("A2");
expect(Ranges.from(R`A0:A2`, R`B0:B2`).at(5).name).toEqual("B2");
});
test("Range(s)#toArray", () => {
const workbook = createWorkbook();
const sheet = createSheet(workbook, "Sheet 1");
sheet.makeCurrent();
let i = 0;
for (const col of ["A", "B"]) {
for (const row of [0, 1, 2]) {
sheet.setCell(col, row, Math.pow(i++, 2));
}
}
sheet.focusCell("A", 0);
expect(R`A0:A2`.toArray().toString()).toEqual("<Cell at A0>,<Cell at A1>,<Cell at A2>");
expect(
Ranges.from(R`A0:A2`, R`B0:B2`)
.toArray()
.toString()
).toEqual("<Cell at A0>,<Cell at A1>,<Cell at A2>,<Cell at B0>,<Cell at B1>,<Cell at B2>");
});
});