Skip to content

Commit

Permalink
[FIX] functions: Fix error message of some Lookup functions
Browse files Browse the repository at this point in the history
Following the refactoring of evaluation, some function calls to
`assertAvailable` were not properly adapted because of the lack of
typing.

closes #5240

Task: 4320993
X-original-commit: 637ae42
Signed-off-by: Adrien Minne (adrm) <[email protected]>
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
rrahir committed Nov 20, 2024
1 parent 006a108 commit fac71e9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/functions/module_lookup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Model } from "../../src/model";
import { activateSheet, createSheet, setCellContent } from "../test_helpers/commands_helpers";
import {
getCellContent,
getCellError,
getEvaluatedCell,
getEvaluatedGrid,
} from "../test_helpers/getters_helpers";
Expand Down Expand Up @@ -848,6 +849,12 @@ describe("VLOOKUP formula", () => {
expect(evaluateCell("A3", { A3: "=VLOOKUP(A1, A1:B2, 2, true)", ...grid })).toBe("#BAD_EXPR");
expect(evaluateCell("A3", { A3: "=VLOOKUP(A1, A1:B2, 2, false)", ...grid })).toBe("#BAD_EXPR");
});

test("Error on key not found displays correctly", () => {
const model = new Model();
setCellContent(model, "A1", "=VLOOKUP(5, B1, 1)");
expect(getCellError(model, "A1")).toBe("Did not find value '5' in VLOOKUP evaluation.");
});
});

describe("HLOOKUP formula", () => {
Expand Down Expand Up @@ -1054,6 +1061,12 @@ describe("HLOOKUP formula", () => {
expect(evaluateCell("A3", { A3: "=HLOOKUP(A1, A1:B2, 2, true)", ...grid })).toBe("#BAD_EXPR");
expect(evaluateCell("A3", { A3: "=HLOOKUP(A1, A1:B2, 2, false)", ...grid })).toBe("#BAD_EXPR");
});

test("Error on key not found displays correctly", () => {
const model = new Model();
setCellContent(model, "A1", "=HLOOKUP(5, B1, 1)");
expect(getCellError(model, "A1")).toBe("Did not find value '5' in HLOOKUP evaluation.");
});
});

describe("XLOOKUP formula", () => {
Expand Down Expand Up @@ -1328,6 +1341,12 @@ describe("XLOOKUP formula", () => {
expect(grid.A1).toBe("#N/A");
expect(grid.A2).toBe("#N/A");
});

test("Error on key not found displays correctly", () => {
const model = new Model();
setCellContent(model, "A1", "=XLOOKUP(5, B1, C1)");
expect(getCellError(model, "A1")).toBe("Did not find value '5' in XLOOKUP evaluation.");
});
});

describe("INDEX formula", () => {
Expand Down

0 comments on commit fac71e9

Please sign in to comment.