mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour tests
As there's a somewhat active development going on, let's keep the expected behaviour under tests to make sure nothing blows up :^)
This commit is contained in:
parent
0fe97cdfe4
commit
bed129a69f
13 changed files with 578 additions and 12 deletions
46
Userland/Applications/Spreadsheet/Tests/test-harness.js
Normal file
46
Userland/Applications/Spreadsheet/Tests/test-harness.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
describe("Harness-defined functions", () => {
|
||||
test("createWorkbook", () => {
|
||||
expect(createWorkbook).toBeDefined();
|
||||
const workbook = createWorkbook();
|
||||
expect(workbook).toBeDefined();
|
||||
expect(workbook.sheet).toBeDefined();
|
||||
});
|
||||
test("createSheet", () => {
|
||||
const workbook = createWorkbook();
|
||||
const sheet = createSheet(workbook, "foo");
|
||||
expect(sheet).toBeDefined();
|
||||
expect(sheet.get_real_cell_contents).toBeDefined();
|
||||
expect(sheet.set_real_cell_contents).toBeDefined();
|
||||
expect(sheet.parse_cell_name).toBeDefined();
|
||||
expect(sheet.current_cell_position).toBeDefined();
|
||||
expect(sheet.column_index).toBeDefined();
|
||||
expect(sheet.column_arithmetic).toBeDefined();
|
||||
expect(sheet.get_column_bound).toBeDefined();
|
||||
});
|
||||
test("Sheet mock behavior", () => {
|
||||
const workbook = createWorkbook();
|
||||
const sheet = createSheet(workbook, "foo");
|
||||
sheet.setCell("A", 0, "10");
|
||||
expect(sheet.getCell("A", 0)).toEqual(["10", "10"]);
|
||||
|
||||
sheet.setCell("A", 0, "=10");
|
||||
expect(sheet.getCell("A", 0)).toEqual(["=10", 10]);
|
||||
|
||||
expect(sheet.getColumns()).toEqual(["A"]);
|
||||
});
|
||||
test("Workbook mock behavior", () => {
|
||||
const workbook = createWorkbook();
|
||||
const sheet = createSheet(workbook, "foo");
|
||||
expect(workbook.sheet("foo")).toBe(sheet);
|
||||
expect(workbook.sheet(0)).toBe(sheet);
|
||||
expect(workbook.sheet(1)).toBeUndefined();
|
||||
expect(workbook.sheet("bar")).toBeUndefined();
|
||||
});
|
||||
test("Referencing cells", () => {
|
||||
const workbook = createWorkbook();
|
||||
const sheet = createSheet(workbook, "foo");
|
||||
sheet.setCell("A", 0, "42");
|
||||
sheet.setCell("A", 1, "=A0");
|
||||
expect(sheet.getCell("A", 1)).toEqual(["=A0", "42"]);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue