diff options
author | u9g <git@u9g.dev> | 2022-03-02 18:30:14 -0500 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2022-03-04 04:29:20 +0330 |
commit | 93115ee0449dff2601fb0f005789fcad7ee91709 (patch) | |
tree | c2075b0746e35fff891868a4b32b3dce3bf7d233 /Userland/Applications | |
parent | 6302ca00431b96d22dbc68a2fa60d0e569775b13 (diff) | |
download | serenity-93115ee0449dff2601fb0f005789fcad7ee91709.zip |
Spreadsheet: Add Range(s).toArray()
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/Spreadsheet/Tests/basic.js | 27 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/Tests/mock.test-common.js | 2 |
2 files changed, 26 insertions, 3 deletions
diff --git a/Userland/Applications/Spreadsheet/Tests/basic.js b/Userland/Applications/Spreadsheet/Tests/basic.js index 07ee7df695..85b6fb3100 100644 --- a/Userland/Applications/Spreadsheet/Tests/basic.js +++ b/Userland/Applications/Spreadsheet/Tests/basic.js @@ -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>"); + }); }); diff --git a/Userland/Applications/Spreadsheet/Tests/mock.test-common.js b/Userland/Applications/Spreadsheet/Tests/mock.test-common.js index 4aa7dcaab5..7a35cc4f9a 100644 --- a/Userland/Applications/Spreadsheet/Tests/mock.test-common.js +++ b/Userland/Applications/Spreadsheet/Tests/mock.test-common.js @@ -136,7 +136,7 @@ class Sheet { if (column !== name) continue; bound = Math.max(bound, row); } - return row; + return bound; } evaluate(currentColumn, currentRow, expression) { |