@odoo/o-spreadsheet 14.0.0 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +20 -0
- package/.husky/post-checkout +9 -0
- package/.husky/pre-commit +39 -0
- package/.prettierignore +1 -0
- package/astToFormula.patch +0 -0
- package/demo/data.js +255 -0
- package/demo/index.html +9 -0
- package/demo/libs/Chart.bundle.js +20755 -0
- package/demo/main.js +101 -0
- package/doc/readme.md +46 -0
- package/package.json +3 -17
- package/rollup.config.js +23 -0
- package/src/base_plugin.ts +102 -0
- package/src/components/autofill.ts +146 -0
- package/src/components/bottom_bar.ts +199 -0
- package/src/components/color_picker.ts +150 -0
- package/src/components/composer/autocomplete_dropdown.ts +135 -0
- package/src/components/composer/composer.ts +487 -0
- package/src/components/composer/content_editable_helper.ts +146 -0
- package/src/components/figures/chart.ts +70 -0
- package/src/components/figures/container.ts +268 -0
- package/src/components/figures/text_figure.ts +36 -0
- package/src/components/grid.ts +635 -0
- package/src/components/helpers/dom_helpers.ts +7 -0
- package/src/components/helpers/drag_and_drop.ts +17 -0
- package/src/components/icons.ts +36 -0
- package/src/components/index.ts +1 -0
- package/src/components/menu.ts +288 -0
- package/src/components/overlay.ts +457 -0
- package/src/components/scrollbar.ts +22 -0
- package/src/components/selection_input.ts +168 -0
- package/src/components/side_panel/cell_is_rule_editor.ts +169 -0
- package/src/components/side_panel/chart_panel.ts +104 -0
- package/src/components/side_panel/color_scale_rule_editor.ts +145 -0
- package/src/components/side_panel/conditional_formatting.ts +396 -0
- package/src/components/side_panel/side_panel.ts +127 -0
- package/src/components/side_panel/translations_terms.ts +45 -0
- package/src/components/spreadsheet.ts +198 -0
- package/src/components/top_bar.ts +535 -0
- package/src/constants.ts +26 -0
- package/src/data.ts +149 -0
- package/src/fonts.ts +41 -0
- package/src/formulas/compiler.ts +258 -0
- package/src/formulas/composer_tokenizer.ts +70 -0
- package/src/formulas/index.ts +15 -0
- package/src/formulas/normalize.ts +52 -0
- package/src/formulas/parser.ts +280 -0
- package/src/formulas/range_tokenizer.ts +97 -0
- package/src/formulas/tokenizer.ts +242 -0
- package/src/functions/arguments.ts +114 -0
- package/src/functions/dates.ts +302 -0
- package/src/functions/helpers.ts +592 -0
- package/src/functions/index.ts +52 -0
- package/src/functions/module_database.ts +282 -0
- package/src/functions/module_date.ts +743 -0
- package/src/functions/module_info.ts +69 -0
- package/src/functions/module_logical.ts +208 -0
- package/src/functions/module_lookup.ts +185 -0
- package/src/functions/module_math.ts +1252 -0
- package/src/functions/module_operators.ts +291 -0
- package/src/functions/module_statistical.ts +882 -0
- package/src/functions/module_text.ts +370 -0
- package/src/helpers/color.ts +30 -0
- package/src/helpers/coordinates.ts +71 -0
- package/src/helpers/grid_manipulation.ts +68 -0
- package/src/helpers/index.ts +7 -0
- package/src/helpers/misc.ts +76 -0
- package/src/helpers/numbers.ts +117 -0
- package/src/helpers/uuid.ts +19 -0
- package/src/helpers/zones.ts +263 -0
- package/src/history.ts +186 -0
- package/src/index.ts +84 -0
- package/src/model.ts +261 -0
- package/src/plugins/autofill.ts +412 -0
- package/src/plugins/chart.ts +404 -0
- package/src/plugins/clipboard.ts +461 -0
- package/src/plugins/conditional_format.ts +445 -0
- package/src/plugins/core.ts +1502 -0
- package/src/plugins/edition.ts +157 -0
- package/src/plugins/evaluation.ts +428 -0
- package/src/plugins/figures.ts +123 -0
- package/src/plugins/formatting.ts +630 -0
- package/src/plugins/highlight.ts +187 -0
- package/src/plugins/index.ts +32 -0
- package/src/plugins/merge.ts +524 -0
- package/src/plugins/renderer.ts +571 -0
- package/src/plugins/selection.ts +562 -0
- package/src/plugins/selection_inputs.ts +326 -0
- package/src/registries/autofill_modifiers.ts +76 -0
- package/src/registries/autofill_rules.ts +98 -0
- package/src/registries/figure_registry.ts +30 -0
- package/src/registries/index.ts +7 -0
- package/src/registries/menu_items_registry.ts +110 -0
- package/src/registries/menus/cell_menu_registry.ts +79 -0
- package/src/registries/menus/col_menu_registry.ts +63 -0
- package/src/registries/menus/index.ts +6 -0
- package/src/registries/menus/menu_items_actions.ts +425 -0
- package/src/registries/menus/row_menu_registry.ts +63 -0
- package/src/registries/menus/sheet_menu_registry.ts +75 -0
- package/src/registries/menus/topbar_menu_registry.ts +204 -0
- package/src/registries/side_panel_registry.ts +26 -0
- package/src/registries/topbar_component_registry.ts +12 -0
- package/src/registry.ts +51 -0
- package/src/translation.ts +44 -0
- package/src/types/autofill.ts +48 -0
- package/src/types/chart.ts +26 -0
- package/src/types/commands.ts +716 -0
- package/src/types/conditional_formatting.ts +124 -0
- package/src/types/env.ts +13 -0
- package/src/types/functions.ts +35 -0
- package/src/types/getters.ts +103 -0
- package/src/types/index.ts +20 -0
- package/src/types/misc.ts +143 -0
- package/src/types/rendering.ts +41 -0
- package/src/types/workbook_data.ts +62 -0
- package/tests/__mocks__/uuid.ts +7 -0
- package/tests/canvas.mock.ts +34 -0
- package/tests/components/__mocks__/content_editable_helper.ts +79 -0
- package/tests/components/__mocks__/scrollbar.ts +18 -0
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +29 -0
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +75 -0
- package/tests/components/__snapshots__/context_menu_test.ts.snap +88 -0
- package/tests/components/__snapshots__/grid_test.ts.snap +60 -0
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +455 -0
- package/tests/components/__snapshots__/top_bar_test.ts.snap +705 -0
- package/tests/components/autocomplete_dropdown_test.ts +315 -0
- package/tests/components/autofill_test.ts +167 -0
- package/tests/components/bottom_bar_test.ts +262 -0
- package/tests/components/chart_side_panel_test.ts +123 -0
- package/tests/components/composer_test.ts +400 -0
- package/tests/components/context_menu_test.ts +825 -0
- package/tests/components/grid_manipulation_test.ts +163 -0
- package/tests/components/grid_test.ts +581 -0
- package/tests/components/overlay_test.ts +541 -0
- package/tests/components/selection_input_test.ts +259 -0
- package/tests/components/side_panel_test.ts +148 -0
- package/tests/components/spreadsheet_test.ts +194 -0
- package/tests/components/top_bar_test.ts +427 -0
- package/tests/data_test.ts +175 -0
- package/tests/dom_helper.ts +42 -0
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +302 -0
- package/tests/formulas/compiler_test.ts +266 -0
- package/tests/formulas/composer_tokenizer_test.ts +137 -0
- package/tests/formulas/expressions_test.ts +57 -0
- package/tests/formulas/formulas_test.ts +80 -0
- package/tests/formulas/normalize_test.ts +82 -0
- package/tests/formulas/parser_test.ts +224 -0
- package/tests/formulas/range_tokenizer_test.ts +187 -0
- package/tests/formulas/tokenizer_test.ts +164 -0
- package/tests/functions/arguments_test.ts +141 -0
- package/tests/functions/dates_test.ts +1081 -0
- package/tests/functions/functions_test.ts +53 -0
- package/tests/functions/helper_test.ts +98 -0
- package/tests/functions/module_database_test.ts +311 -0
- package/tests/functions/module_date_test.ts +941 -0
- package/tests/functions/module_info_test.ts +139 -0
- package/tests/functions/module_logical_test.ts +369 -0
- package/tests/functions/module_lookup_test.ts +541 -0
- package/tests/functions/module_math_test.ts +2482 -0
- package/tests/functions/module_operators_test.ts +955 -0
- package/tests/functions/module_statistical_test.ts +2014 -0
- package/tests/functions/module_text_test.ts +667 -0
- package/tests/helpers/coordinates_test.ts +25 -0
- package/tests/helpers/misc_test.ts +95 -0
- package/tests/helpers/numbers_test.ts +196 -0
- package/tests/helpers/zones_test.ts +97 -0
- package/tests/helpers.ts +384 -0
- package/tests/menu_items_registry_test.ts +540 -0
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +90 -0
- package/tests/model/plugins/chart_test.ts +562 -0
- package/tests/model_test.ts +82 -0
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +131 -0
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +371 -0
- package/tests/plugins/autofill_test.ts +457 -0
- package/tests/plugins/borders_test.ts +295 -0
- package/tests/plugins/clipboard_test.ts +1180 -0
- package/tests/plugins/conditional_formatting_test.ts +1253 -0
- package/tests/plugins/core_test.ts +614 -0
- package/tests/plugins/edition_test.ts +100 -0
- package/tests/plugins/evaluation_async_test.ts +332 -0
- package/tests/plugins/evaluation_dates_test.ts +79 -0
- package/tests/plugins/evaluation_test.ts +901 -0
- package/tests/plugins/figures_test.ts +327 -0
- package/tests/plugins/formatting_test.ts +391 -0
- package/tests/plugins/grid_manipulation_test.ts +1366 -0
- package/tests/plugins/highlight_test.ts +413 -0
- package/tests/plugins/history_test.ts +142 -0
- package/tests/plugins/import_export_test.ts +276 -0
- package/tests/plugins/merges_test.ts +490 -0
- package/tests/plugins/navigation_test.ts +181 -0
- package/tests/plugins/plugins/evaluation_test.ts +111 -0
- package/tests/plugins/renderer_test.ts +598 -0
- package/tests/plugins/resizing_test.ts +152 -0
- package/tests/plugins/selection_input_test.ts +409 -0
- package/tests/plugins/selection_test.ts +442 -0
- package/tests/plugins/sheets_test.ts +643 -0
- package/tests/plugins/style_test.ts +90 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,667 @@
|
|
|
1
|
+
import { evaluateCell, evaluateGrid } from "../helpers";
|
|
2
|
+
|
|
3
|
+
describe("text", () => {
|
|
4
|
+
//----------------------------------------------------------------------------
|
|
5
|
+
// CHAR
|
|
6
|
+
//----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
test("CHAR: functional tests on simple arguments", () => {
|
|
9
|
+
expect(evaluateCell("A1", { A1: "=CHAR()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
10
|
+
expect(evaluateCell("A1", { A1: "=CHAR(65)" })).toBe("A");
|
|
11
|
+
expect(evaluateCell("A1", { A1: "=CHAR(122)" })).toBe("z");
|
|
12
|
+
expect(evaluateCell("A1", { A1: "=CHAR(57)" })).toBe("9");
|
|
13
|
+
expect(evaluateCell("A1", { A1: "=CHAR(-1)" })).toBe("#ERROR"); // @compatibility: on google sheets, return #NUM!
|
|
14
|
+
expect(evaluateCell("A1", { A1: "=CHAR(65.9)" })).toBe("A");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("CHAR: casting tests on simple arguments", () => {
|
|
18
|
+
expect(evaluateCell("A1", { A1: '=CHAR("65")' })).toBe("A");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("CHAR: functional tests on cell arguments", () => {
|
|
22
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)" })).toBe("#ERROR"); // @compatibility: on google sheets, return #NUM!
|
|
23
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: "66" })).toBe("B");
|
|
24
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: "121" })).toBe("y");
|
|
25
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: "56" })).toBe("8");
|
|
26
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: "-1" })).toBe("#ERROR"); // @compatibility: on google sheets, return #NUM!
|
|
27
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: "66.9" })).toBe("B");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("CHAR: casting tests on cell arguments", () => {
|
|
31
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: '"68"' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
32
|
+
expect(evaluateCell("A1", { A1: "=CHAR(A2)", A2: '="68"' })).toBe("D");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
//----------------------------------------------------------------------------
|
|
36
|
+
// CONCATENATE
|
|
37
|
+
//----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
test("CONCATENATE: functional tests on simple arguments", () => {
|
|
40
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
41
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE( , )" })).toBe("");
|
|
42
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE( , 1)" })).toBe("1");
|
|
43
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(42)" })).toBe("42");
|
|
44
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(42, 24)" })).toBe("4224");
|
|
45
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(42, -24)" })).toBe("42-24");
|
|
46
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(42, 0.42)" })).toBe("420.42");
|
|
47
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(42, 42%)" })).toBe("420.42");
|
|
48
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE(1, "")' })).toBe("1");
|
|
49
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE(1, " ")' })).toBe("1 ");
|
|
50
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE(1, "3")' })).toBe("13");
|
|
51
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE(1, "-3")' })).toBe("1-3");
|
|
52
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(1, TRUE)" })).toBe("1TRUE");
|
|
53
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(1, FALSE)" })).toBe("1FALSE");
|
|
54
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE(1, "3%")' })).toBe("13%");
|
|
55
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE("ki", "kou")' })).toBe("kikou");
|
|
56
|
+
expect(evaluateCell("A1", { A1: '=CONCATENATE("TRUE", TRUE)' })).toBe("TRUETRUE");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("CONCATENATE: functional tests on cell arguments", () => {
|
|
60
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)" })).toBe("");
|
|
61
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "1" })).toBe("1");
|
|
62
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "1", A3: "42" })).toBe("142");
|
|
63
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: '""' })).toBe('42""');
|
|
64
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: '"42"' })).toBe('42"42"');
|
|
65
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: "TRUE" })).toBe("42TRUE");
|
|
66
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: '"TRUE"', A3: "TRUE" })).toBe(
|
|
67
|
+
'"TRUE"TRUE'
|
|
68
|
+
);
|
|
69
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: '=""' })).toBe("42");
|
|
70
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: '=" "' })).toBe("42 ");
|
|
71
|
+
expect(evaluateCell("A1", { A1: "=CONCATENATE(A2, A3)", A2: "42", A3: '="24"' })).toBe("4224");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// prettier-ignore
|
|
75
|
+
test("CONCATENATE: functional tests on range arguments", () => {
|
|
76
|
+
const grid = {
|
|
77
|
+
A1: "=CONCATENATE(A2:A4)",
|
|
78
|
+
B1: "=CONCATENATE(B2:B4)",
|
|
79
|
+
C1: "=CONCATENATE(C2:C4)",
|
|
80
|
+
|
|
81
|
+
A2: "9", A3: "test", A4: '"42"',
|
|
82
|
+
B2: "tRuE", B3: '="123"', B4: '="tset"',
|
|
83
|
+
C2: "7%", C3: '"8%"', C4: '=""',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const gridResult = evaluateGrid(grid);
|
|
87
|
+
expect(gridResult.A1).toBe('9test"42"');
|
|
88
|
+
expect(gridResult.B1).toBe("TRUE123tset");
|
|
89
|
+
expect(gridResult.C1).toBe('0.07"8%"');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
//----------------------------------------------------------------------------
|
|
93
|
+
// EXACT
|
|
94
|
+
//----------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
test("EXACT: functional tests on simple arguments", () => {
|
|
97
|
+
expect(evaluateCell("A1", { A1: "=EXACT(,)" })).toBe(true);
|
|
98
|
+
expect(evaluateCell("A1", { A1: '=EXACT(,"")' })).toBe(true);
|
|
99
|
+
expect(evaluateCell("A1", { A1: '=EXACT("test","test")' })).toBe(true);
|
|
100
|
+
expect(evaluateCell("A1", { A1: '=EXACT("test","Test")' })).toBe(false);
|
|
101
|
+
expect(evaluateCell("A1", { A1: '=EXACT("test"," test ")' })).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("EXACT: casting tests on simple arguments", () => {
|
|
105
|
+
expect(evaluateCell("A1", { A1: "=EXACT(123, 123)" })).toBe(true);
|
|
106
|
+
expect(evaluateCell("A1", { A1: "=EXACT(123, 1234)" })).toBe(false);
|
|
107
|
+
expect(evaluateCell("A1", { A1: '=EXACT(123, "123")' })).toBe(true);
|
|
108
|
+
expect(evaluateCell("A1", { A1: '=EXACT(TRUE, "TRUE")' })).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("EXACT: functional tests on cell arguments", () => {
|
|
112
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)" })).toBe(true);
|
|
113
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "test", A3: "test" })).toBe(true);
|
|
114
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "test", A3: "Test" })).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("EXACT: casting tests on cell arguments", () => {
|
|
118
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "TRUE", A3: "TRUE" })).toBe(true);
|
|
119
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "TRUE", A3: "FALSE" })).toBe(false);
|
|
120
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "456", A3: "456" })).toBe(true);
|
|
121
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "456", A3: '"456"' })).toBe(false);
|
|
122
|
+
expect(evaluateCell("A1", { A1: "=EXACT(A2, A3)", A2: "456", A3: '="456"' })).toBe(true);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
//----------------------------------------------------------------------------
|
|
126
|
+
// FIND
|
|
127
|
+
//----------------------------------------------------------------------------
|
|
128
|
+
|
|
129
|
+
test("FIND: functional tests on simple arguments", () => {
|
|
130
|
+
expect(evaluateCell("A1", { A1: "=FIND( , )" })).toBe("#ERROR"); // @compatibility: on google sheets, return #N/A
|
|
131
|
+
expect(evaluateCell("A1", { A1: '=FIND("", "")' })).toBe("#ERROR"); // @compatibility: on google sheets, return #N/A
|
|
132
|
+
expect(evaluateCell("A1", { A1: "=FIND( , , )" })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
133
|
+
expect(evaluateCell("A1", { A1: '=FIND( , "", )' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
134
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD")' })).toBe(3);
|
|
135
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD", 0)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
136
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD", 1)' })).toBe(3);
|
|
137
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD", 2)' })).toBe(3);
|
|
138
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD", 3)' })).toBe(3);
|
|
139
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCD", 4)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
140
|
+
expect(evaluateCell("A1", { A1: '=FIND("C", "ABCDC", 4)' })).toBe(5);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("FIND: functional tests on cell arguments", () => {
|
|
144
|
+
expect(evaluateCell("A1", { A1: "=FIND(A2, A3)", A2: "do", A3: "Odoo" })).toBe(2);
|
|
145
|
+
expect(
|
|
146
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "do", A3: "Odoo Docs", A4: "1" })
|
|
147
|
+
).toBe(2);
|
|
148
|
+
expect(
|
|
149
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "do", A3: "Odoo Docs", A4: "4" })
|
|
150
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
151
|
+
expect(
|
|
152
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "1" })
|
|
153
|
+
).toBe(1);
|
|
154
|
+
expect(
|
|
155
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "6" })
|
|
156
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
157
|
+
expect(
|
|
158
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "8" })
|
|
159
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
160
|
+
expect(evaluateCell("A1", { A1: "=FIND(A2, A3)", A2: "7", A3: "No.7 Doc" })).toBe(4);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("FIND: casting tests on cell arguments", () => {
|
|
164
|
+
expect(
|
|
165
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: '="6"' })
|
|
166
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
167
|
+
expect(
|
|
168
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "TRUE" })
|
|
169
|
+
).toBe(1);
|
|
170
|
+
expect(evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "U", A3: "TRUE", A4: "1" })).toBe(3);
|
|
171
|
+
expect(
|
|
172
|
+
evaluateCell("A1", { A1: "=FIND(A2, A3, A4)", A2: "TRUE", A3: "FALSETRUE", A4: "1" })
|
|
173
|
+
).toBe(6);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
//----------------------------------------------------------------------------
|
|
177
|
+
// JOIN
|
|
178
|
+
//----------------------------------------------------------------------------
|
|
179
|
+
|
|
180
|
+
test("JOIN: functional tests on simple arguments", () => {
|
|
181
|
+
expect(evaluateCell("A1", { A1: "=JOIN()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
182
|
+
expect(evaluateCell("A1", { A1: "=JOIN( , )" })).toBe("");
|
|
183
|
+
expect(evaluateCell("A1", { A1: "=JOIN( , 1)" })).toBe("1");
|
|
184
|
+
expect(evaluateCell("A1", { A1: '=JOIN("-", 1)' })).toBe("1");
|
|
185
|
+
expect(evaluateCell("A1", { A1: "=JOIN( , 1, 2, 3)" })).toBe("123");
|
|
186
|
+
expect(evaluateCell("A1", { A1: '=JOIN("", 1, 2, 3)' })).toBe("123");
|
|
187
|
+
expect(evaluateCell("A1", { A1: '=JOIN("-", 1, 2, 3)' })).toBe("1-2-3");
|
|
188
|
+
expect(evaluateCell("A1", { A1: '=JOIN("9", 1, 2, 3)' })).toBe("19293");
|
|
189
|
+
expect(evaluateCell("A1", { A1: '=JOIN(9, "1", "2", "3")' })).toBe("19293");
|
|
190
|
+
expect(evaluateCell("A1", { A1: "=JOIN(TRUE, 1, 2, 3)" })).toBe("1TRUE2TRUE3");
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test("JOIN: functional tests on cell arguments", () => {
|
|
194
|
+
expect(evaluateCell("A1", { A1: "=JOIN(A2, A3)" })).toBe("");
|
|
195
|
+
expect(evaluateCell("A1", { A1: "=JOIN(A2, A3)", A3: "1" })).toBe("1");
|
|
196
|
+
expect(evaluateCell("A1", { A1: "=JOIN(A2, A3)", A2: "-", A3: "1" })).toBe("1");
|
|
197
|
+
expect(evaluateCell("A1", { A1: "=JOIN(A2, A3, A4, A5)", A3: "1", A4: "2", A5: "3" })).toBe(
|
|
198
|
+
"123"
|
|
199
|
+
);
|
|
200
|
+
expect(
|
|
201
|
+
evaluateCell("A1", { A1: "=JOIN(A2, A3, A4, A5)", A2: '=""', A3: "1", A4: "2", A5: "3" })
|
|
202
|
+
).toBe("123");
|
|
203
|
+
expect(
|
|
204
|
+
evaluateCell("A1", { A1: "=JOIN(A2, A3, A4, A5)", A2: "-", A3: "1", A4: "2", A5: "3" })
|
|
205
|
+
).toBe("1-2-3");
|
|
206
|
+
expect(
|
|
207
|
+
evaluateCell("A1", { A1: "=JOIN(A2, A3, A4, A5)", A2: '="9"', A3: "1", A4: "2", A5: "3" })
|
|
208
|
+
).toBe("19293");
|
|
209
|
+
expect(
|
|
210
|
+
evaluateCell("A1", {
|
|
211
|
+
A1: "=JOIN(A2, A3, A4, A5)",
|
|
212
|
+
A2: "9",
|
|
213
|
+
A3: '="1"',
|
|
214
|
+
A4: '="2"',
|
|
215
|
+
A5: '="3"',
|
|
216
|
+
})
|
|
217
|
+
).toBe("19293");
|
|
218
|
+
expect(
|
|
219
|
+
evaluateCell("A1", { A1: "=JOIN(A2, A3, A4, A5)", A2: "TRUE", A3: "1", A4: "2", A5: "3" })
|
|
220
|
+
).toBe("1TRUE2TRUE3");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// prettier-ignore
|
|
224
|
+
test("JOIN: functional tests on range arguments", () => {
|
|
225
|
+
const grid = {
|
|
226
|
+
A1: '=JOIN("*", A2:A4)',
|
|
227
|
+
B1: '=JOIN(42, B2:B4)',
|
|
228
|
+
C1: '=JOIN(",", C2:C4)',
|
|
229
|
+
|
|
230
|
+
A2: "9", A3: "test", A4: '"42"',
|
|
231
|
+
B2: "tRuE", B3: '="123"', B4: '="tset"',
|
|
232
|
+
C2: "7%", C3: '"8%"', C4: '=""',
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const gridResult = evaluateGrid(grid);
|
|
236
|
+
expect(gridResult.A1).toBe('9*test*"42"');
|
|
237
|
+
expect(gridResult.B1).toBe("TRUE4212342tset");
|
|
238
|
+
expect(gridResult.C1).toBe('0.07,"8%",');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
//----------------------------------------------------------------------------
|
|
242
|
+
// LEFT
|
|
243
|
+
//----------------------------------------------------------------------------
|
|
244
|
+
|
|
245
|
+
test("LEFT: functional tests on simple arguments", () => {
|
|
246
|
+
expect(evaluateCell("A1", { A1: "=LEFT()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
247
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou")' })).toBe("k");
|
|
248
|
+
expect(evaluateCell("A1", { A1: '=LEFT("123")' })).toBe("1");
|
|
249
|
+
expect(evaluateCell("A1", { A1: "=LEFT(123)" })).toBe("1");
|
|
250
|
+
expect(evaluateCell("A1", { A1: "=LEFT(TRUE)" })).toBe("T");
|
|
251
|
+
expect(evaluateCell("A1", { A1: "=LEFT( , )" })).toBe("");
|
|
252
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", )' })).toBe("");
|
|
253
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", -1)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
254
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", 0)' })).toBe("");
|
|
255
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", 1)' })).toBe("k");
|
|
256
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", 2)' })).toBe("ki");
|
|
257
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", 6)' })).toBe("kikou");
|
|
258
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", 99)' })).toBe("kikou");
|
|
259
|
+
expect(evaluateCell("A1", { A1: '=LEFT("kikou", "2")' })).toBe("ki");
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("LEFT: functional tests on cell arguments", () => {
|
|
263
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2)" })).toBe("");
|
|
264
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2)", A2: "kikou" })).toBe("k");
|
|
265
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2)", A2: '="123"' })).toBe("1");
|
|
266
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2)", A2: "123" })).toBe("1");
|
|
267
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2)", A2: "TRUE" })).toBe("T");
|
|
268
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)" })).toBe("");
|
|
269
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou" })).toBe("");
|
|
270
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "-1" })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
271
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "0" })).toBe("");
|
|
272
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "1" })).toBe("k");
|
|
273
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "2" })).toBe("ki");
|
|
274
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "6" })).toBe("kikou");
|
|
275
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: "99" })).toBe("kikou");
|
|
276
|
+
expect(evaluateCell("A1", { A1: "=LEFT(A2, A3)", A2: "kikou", A3: '="2"' })).toBe("ki");
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
//----------------------------------------------------------------------------
|
|
280
|
+
// LEN
|
|
281
|
+
//----------------------------------------------------------------------------
|
|
282
|
+
|
|
283
|
+
test("LEN: functional tests on simple arguments", () => {
|
|
284
|
+
expect(evaluateCell("A1", { A1: "=LEN()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
285
|
+
expect(evaluateCell("A1", { A1: "=LEN(0)" })).toBe(1);
|
|
286
|
+
expect(evaluateCell("A1", { A1: "=LEN(42)" })).toBe(2);
|
|
287
|
+
expect(evaluateCell("A1", { A1: "=LEN(-4.42)" })).toBe(5);
|
|
288
|
+
expect(evaluateCell("A1", { A1: "=LEN(TRUE)" })).toBe(4);
|
|
289
|
+
expect(evaluateCell("A1", { A1: "=LEN(FALSE)" })).toBe(5);
|
|
290
|
+
expect(evaluateCell("A1", { A1: "=LEN(FALSE)" })).toBe(5);
|
|
291
|
+
expect(evaluateCell("A1", { A1: '=LEN("")' })).toBe(0);
|
|
292
|
+
expect(evaluateCell("A1", { A1: '=LEN(" ")' })).toBe(1);
|
|
293
|
+
expect(evaluateCell("A1", { A1: '=LEN("42")' })).toBe(2);
|
|
294
|
+
expect(evaluateCell("A1", { A1: '=LEN("オドゥ")' })).toBe(3);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
test("LEN: functional tests on cell arguments", () => {
|
|
298
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)" })).toBe(0);
|
|
299
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: " " })).toBe(1);
|
|
300
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: "0" })).toBe(1);
|
|
301
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: "42" })).toBe(2);
|
|
302
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: "TRUE" })).toBe(4);
|
|
303
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: "FALSE" })).toBe(5);
|
|
304
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '""' })).toBe(2);
|
|
305
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '" "' })).toBe(3);
|
|
306
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '"42"' })).toBe(4);
|
|
307
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '=""' })).toBe(0);
|
|
308
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '=" "' })).toBe(1);
|
|
309
|
+
expect(evaluateCell("A1", { A1: "=LEN(A2)", A2: '="42"' })).toBe(2);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
//----------------------------------------------------------------------------
|
|
313
|
+
// LOWER
|
|
314
|
+
//----------------------------------------------------------------------------
|
|
315
|
+
|
|
316
|
+
test("LOWER: functional tests on simple arguments", () => {
|
|
317
|
+
expect(evaluateCell("A1", { A1: "=LOWER()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
318
|
+
expect(evaluateCell("A1", { A1: "=LOWER(0)" })).toBe("0");
|
|
319
|
+
expect(evaluateCell("A1", { A1: "=LOWER(42)" })).toBe("42");
|
|
320
|
+
expect(evaluateCell("A1", { A1: "=LOWER(TRUE)" })).toBe("true");
|
|
321
|
+
expect(evaluateCell("A1", { A1: "=LOWER(FALSE)" })).toBe("false");
|
|
322
|
+
expect(evaluateCell("A1", { A1: '=LOWER("")' })).toBe("");
|
|
323
|
+
expect(evaluateCell("A1", { A1: '=LOWER(" ")' })).toBe(" ");
|
|
324
|
+
expect(evaluateCell("A1", { A1: '=LOWER("42")' })).toBe("42");
|
|
325
|
+
expect(evaluateCell("A1", { A1: '=LOWER("オドゥ")' })).toBe("オドゥ");
|
|
326
|
+
expect(evaluateCell("A1", { A1: '=LOWER("オAドB")' })).toBe("オaドb");
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test("LOWER: functional tests on cell arguments", () => {
|
|
330
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)" })).toBe("");
|
|
331
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: " " })).toBe(" ");
|
|
332
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: "0" })).toBe("0");
|
|
333
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: "42" })).toBe("42");
|
|
334
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: "TRUE" })).toBe("true");
|
|
335
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: "FALSE" })).toBe("false");
|
|
336
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '""' })).toBe('""');
|
|
337
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '" "' })).toBe('" "');
|
|
338
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '"TEST"' })).toBe('"test"');
|
|
339
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '=""' })).toBe("");
|
|
340
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '=" "' })).toBe(" ");
|
|
341
|
+
expect(evaluateCell("A1", { A1: "=LOWER(A2)", A2: '="TEST"' })).toBe("test");
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
//----------------------------------------------------------------------------
|
|
345
|
+
// REPLACE
|
|
346
|
+
//----------------------------------------------------------------------------
|
|
347
|
+
|
|
348
|
+
test("REPLACE: functional tests on simple arguments", () => {
|
|
349
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 2, 1, "Y")' })).toBe("AYZ");
|
|
350
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 3, 1, "Y")' })).toBe("ABY");
|
|
351
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 4, 1, "Y")' })).toBe("ABZY");
|
|
352
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 5, 1, "Y")' })).toBe("ABZY");
|
|
353
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 3, 2, "Y")' })).toBe("ABY");
|
|
354
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 3, 2, " Y")' })).toBe("AB Y");
|
|
355
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 5, 2, " Y")' })).toBe("ABZ Y");
|
|
356
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 2, 2, "Y")' })).toBe("AY");
|
|
357
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 1, 2, "Y")' })).toBe("YZ");
|
|
358
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 0, 2, "Y")' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
359
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 1, 1, "Y")' })).toBe("YBZ");
|
|
360
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 1, 0, "Y")' })).toBe("YABZ");
|
|
361
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", 2, 0, "Y")' })).toBe("AYBZ");
|
|
362
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", -1, 0, "Y")' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test("REPLACE: casting tests on simple arguments", () => {
|
|
366
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("ABZ", "2", TRUE, "Y")' })).toBe("AYZ");
|
|
367
|
+
expect(evaluateCell("A1", { A1: '=REPLACE(1239, 2, 2, "78")' })).toBe("1789");
|
|
368
|
+
expect(evaluateCell("A1", { A1: '=REPLACE("1789", 2, 2, 23)' })).toBe("1239");
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
//----------------------------------------------------------------------------
|
|
372
|
+
// RIGHT
|
|
373
|
+
//----------------------------------------------------------------------------
|
|
374
|
+
|
|
375
|
+
test("RIGHT: functional tests on simple arguments", () => {
|
|
376
|
+
expect(evaluateCell("A1", { A1: "=RIGHT()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
377
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou")' })).toBe("u");
|
|
378
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("123")' })).toBe("3");
|
|
379
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(123)" })).toBe("3");
|
|
380
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(TRUE)" })).toBe("E");
|
|
381
|
+
expect(evaluateCell("A1", { A1: "=RIGHT( , )" })).toBe("");
|
|
382
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", )' })).toBe("");
|
|
383
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", -1)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
384
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", 0)' })).toBe("");
|
|
385
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", 1)' })).toBe("u");
|
|
386
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", 2)' })).toBe("ou");
|
|
387
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", 6)' })).toBe("kikou");
|
|
388
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", 99)' })).toBe("kikou");
|
|
389
|
+
expect(evaluateCell("A1", { A1: '=RIGHT("kikou", "2")' })).toBe("ou");
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("RIGHT: functional tests on cell arguments", () => {
|
|
393
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2)" })).toBe("");
|
|
394
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2)", A2: "kikou" })).toBe("u");
|
|
395
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2)", A2: '="123"' })).toBe("3");
|
|
396
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2)", A2: "123" })).toBe("3");
|
|
397
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2)", A2: "TRUE" })).toBe("E");
|
|
398
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)" })).toBe("");
|
|
399
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou" })).toBe("");
|
|
400
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "-1" })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
401
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "0" })).toBe("");
|
|
402
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "1" })).toBe("u");
|
|
403
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "2" })).toBe("ou");
|
|
404
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "6" })).toBe("kikou");
|
|
405
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: "99" })).toBe("kikou");
|
|
406
|
+
expect(evaluateCell("A1", { A1: "=RIGHT(A2, A3)", A2: "kikou", A3: '="2"' })).toBe("ou");
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
//----------------------------------------------------------------------------
|
|
410
|
+
// SEARCH
|
|
411
|
+
//----------------------------------------------------------------------------
|
|
412
|
+
|
|
413
|
+
test("SEARCH: functional tests on simple arguments", () => {
|
|
414
|
+
expect(evaluateCell("A1", { A1: "=SEARCH( , )" })).toBe("#ERROR"); // @compatibility: on google sheets, return #N/A
|
|
415
|
+
expect(evaluateCell("A1", { A1: "=SEARCH( , , )" })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
416
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD")' })).toBe(3);
|
|
417
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD", 0)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
418
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD", 1)' })).toBe(3);
|
|
419
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD", 2)' })).toBe(3);
|
|
420
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD", 3)' })).toBe(3);
|
|
421
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCD", 4)' })).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
422
|
+
expect(evaluateCell("A1", { A1: '=SEARCH("C", "ABCDC", 4)' })).toBe(5);
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
test("SEARCH: functional tests on cell arguments", () => {
|
|
426
|
+
expect(evaluateCell("A1", { A1: "=SEARCH(A2, A3)", A2: "do", A3: "Odoo" })).toBe(2);
|
|
427
|
+
expect(
|
|
428
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "do", A3: "Odoo Docs", A4: "1" })
|
|
429
|
+
).toBe(2);
|
|
430
|
+
expect(
|
|
431
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "do", A3: "Odoo Docs", A4: "4" })
|
|
432
|
+
).toBe(6);
|
|
433
|
+
expect(
|
|
434
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "1" })
|
|
435
|
+
).toBe(1);
|
|
436
|
+
expect(
|
|
437
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "6" })
|
|
438
|
+
).toBe(7);
|
|
439
|
+
expect(
|
|
440
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "8" })
|
|
441
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
442
|
+
expect(evaluateCell("A1", { A1: "=SEARCH(A2, A3)", A2: "7", A3: "No.7 Doc" })).toBe(4);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test("SEARCH: casting tests on cell arguments", () => {
|
|
446
|
+
expect(
|
|
447
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: '="6"' })
|
|
448
|
+
).toBe(7);
|
|
449
|
+
expect(
|
|
450
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "S", A3: "Spreadsheet", A4: "TRUE" })
|
|
451
|
+
).toBe(1);
|
|
452
|
+
expect(evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "U", A3: "TRUE", A4: "1" })).toBe(3);
|
|
453
|
+
expect(
|
|
454
|
+
evaluateCell("A1", { A1: "=SEARCH(A2, A3, A4)", A2: "TRUE", A3: "FALSETRUE", A4: "1" })
|
|
455
|
+
).toBe(6);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
//----------------------------------------------------------------------------
|
|
459
|
+
// SUBSTITUTE
|
|
460
|
+
//----------------------------------------------------------------------------
|
|
461
|
+
|
|
462
|
+
test("SUBSTITUTE: functional tests on simple arguments", () => {
|
|
463
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE( , , )" })).toBe("");
|
|
464
|
+
expect(evaluateCell("A1", { A1: '=SUBSTITUTE("Odoo", "do", "de à Odo")' })).toBe("Ode à Odoo");
|
|
465
|
+
expect(evaluateCell("A1", { A1: '=SUBSTITUTE("odoodoo sur MON bidet", "o", "a")' })).toBe(
|
|
466
|
+
"adaadaa sur MON bidet"
|
|
467
|
+
);
|
|
468
|
+
expect(evaluateCell("A1", { A1: '=SUBSTITUTE("Aa", "a", "b")' })).toBe("Ab");
|
|
469
|
+
expect(evaluateCell("A1", { A1: '=SUBSTITUTE("Spread Sheet", "e", "E", 2)' })).toBe(
|
|
470
|
+
"Spread ShEet"
|
|
471
|
+
);
|
|
472
|
+
expect(evaluateCell("A1", { A1: '=SUBSTITUTE("AAAA", "", "B")' })).toBe("AAAA");
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
test("SUBSTITUTE: functional tests on cell arguments", () => {
|
|
476
|
+
expect(
|
|
477
|
+
evaluateCell("A1", {
|
|
478
|
+
A1: "=SUBSTITUTE(A2, A3, A4)",
|
|
479
|
+
A2: "Coquille",
|
|
480
|
+
A3: "e",
|
|
481
|
+
A4: 'e sans "q"',
|
|
482
|
+
})
|
|
483
|
+
).toBe('Coquille sans "q"');
|
|
484
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "ABAB", A3: "A" })).toBe("BB");
|
|
485
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "AAAA", A3: "A" })).toBe("");
|
|
486
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "AAAA" })).toBe("AAAA");
|
|
487
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "AAAA", A4: "B" })).toBe("AAAA");
|
|
488
|
+
|
|
489
|
+
expect(
|
|
490
|
+
evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "Hello there", A3: "e", A4: "E" })
|
|
491
|
+
).toBe("HEllo thErE");
|
|
492
|
+
expect(
|
|
493
|
+
evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4, A5)", A2: "Hello there", A3: "e", A4: "E" })
|
|
494
|
+
).toBe("HEllo thErE");
|
|
495
|
+
expect(
|
|
496
|
+
evaluateCell("A1", {
|
|
497
|
+
A1: "=SUBSTITUTE(A2, A3, A4, A5)",
|
|
498
|
+
A2: "Hello there",
|
|
499
|
+
A3: "e",
|
|
500
|
+
A4: "E",
|
|
501
|
+
A5: "0",
|
|
502
|
+
})
|
|
503
|
+
).toBe("HEllo thErE");
|
|
504
|
+
expect(
|
|
505
|
+
evaluateCell("A1", {
|
|
506
|
+
A1: "=SUBSTITUTE(A2, A3, A4, A5)",
|
|
507
|
+
A2: "Hello there",
|
|
508
|
+
A3: "e",
|
|
509
|
+
A4: "E",
|
|
510
|
+
A5: "1",
|
|
511
|
+
})
|
|
512
|
+
).toBe("HEllo there");
|
|
513
|
+
expect(
|
|
514
|
+
evaluateCell("A1", {
|
|
515
|
+
A1: "=SUBSTITUTE(A2, A3, A4, A5)",
|
|
516
|
+
A2: "Hello there",
|
|
517
|
+
A3: "e",
|
|
518
|
+
A4: "E",
|
|
519
|
+
A5: "2",
|
|
520
|
+
})
|
|
521
|
+
).toBe("Hello thEre");
|
|
522
|
+
expect(
|
|
523
|
+
evaluateCell("A1", {
|
|
524
|
+
A1: "=SUBSTITUTE(A2, A3, A4, A5)",
|
|
525
|
+
A2: "Hello there",
|
|
526
|
+
A3: "e",
|
|
527
|
+
A4: "E",
|
|
528
|
+
A5: "-1",
|
|
529
|
+
})
|
|
530
|
+
).toBe("#ERROR"); // @compatibility: on google sheets, return #VALUE!
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
test("SUBSTITUTE: casting tests on cell arguments", () => {
|
|
534
|
+
expect(evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "22", A3: "2", A4: "99" })).toBe(
|
|
535
|
+
"9999"
|
|
536
|
+
);
|
|
537
|
+
expect(
|
|
538
|
+
evaluateCell("A1", {
|
|
539
|
+
A1: "=SUBSTITUTE(A2, A3, A4, A5)",
|
|
540
|
+
A2: "2222",
|
|
541
|
+
A3: "2",
|
|
542
|
+
A4: "99",
|
|
543
|
+
A5: "3",
|
|
544
|
+
})
|
|
545
|
+
).toBe("22992");
|
|
546
|
+
expect(
|
|
547
|
+
evaluateCell("A1", { A1: "=SUBSTITUTE(A2, A3, A4)", A2: "TRUE", A3: "E", A4: "QUE" })
|
|
548
|
+
).toBe("TRUQUE");
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
//----------------------------------------------------------------------------
|
|
552
|
+
// TEXTJOIN
|
|
553
|
+
//----------------------------------------------------------------------------
|
|
554
|
+
|
|
555
|
+
test("TEXTJOIN: functional tests on simple arguments", () => {
|
|
556
|
+
expect(evaluateCell("A1", { A1: "=TEXTJOIN( , , )" })).toBe("");
|
|
557
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN("d", TRUE, "O", "oo", "oo", "oo")' })).toBe(
|
|
558
|
+
"Odoodoodoo"
|
|
559
|
+
);
|
|
560
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", TRUE, "1", "2", "3", "", "4")' })).toBe(
|
|
561
|
+
"1 2 3 4"
|
|
562
|
+
);
|
|
563
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", TRUE, "1", "2", "3", , "4")' })).toBe(
|
|
564
|
+
"1 2 3 4"
|
|
565
|
+
);
|
|
566
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", FALSE, "1", "2", "3", "", "4")' })).toBe(
|
|
567
|
+
"1 2 3 4"
|
|
568
|
+
);
|
|
569
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", FALSE, "1", "2", "3", , "4")' })).toBe(
|
|
570
|
+
"1 2 3 4"
|
|
571
|
+
);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
test("TEXTJOIN: casting tests on simple arguments", () => {
|
|
575
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", TRUE, 1, 2, 3, , 4)' })).toBe("1 2 3 4");
|
|
576
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", FALSE, 1, 2, 3, , 4)' })).toBe("1 2 3 4");
|
|
577
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", 1, "1", "2", "3", "", "4")' })).toBe("1 2 3 4");
|
|
578
|
+
expect(evaluateCell("A1", { A1: '=TEXTJOIN(" ", 0, "1", "2", "3", "", "4")' })).toBe(
|
|
579
|
+
"1 2 3 4"
|
|
580
|
+
);
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
test("TEXTJOIN: functional tests on cell arguments", () => {
|
|
584
|
+
expect(
|
|
585
|
+
evaluateCell("A1", {
|
|
586
|
+
A1: "=TEXTJOIN(A2, A3, A4:A6)",
|
|
587
|
+
A2: "PINCE",
|
|
588
|
+
A3: "FALSE",
|
|
589
|
+
A5: "MI et ",
|
|
590
|
+
A6: "MOI sont dans un bateau",
|
|
591
|
+
})
|
|
592
|
+
).toBe("PINCEMI et PINCEMOI sont dans un bateau");
|
|
593
|
+
expect(
|
|
594
|
+
evaluateCell("A1", {
|
|
595
|
+
A1: "=TEXTJOIN(A2, A3, A4:A6)",
|
|
596
|
+
A2: "PINCE",
|
|
597
|
+
A3: "TRUE",
|
|
598
|
+
A5: "MI et ",
|
|
599
|
+
A6: "MOI sont dans un bateau",
|
|
600
|
+
})
|
|
601
|
+
).toBe("MI et PINCEMOI sont dans un bateau");
|
|
602
|
+
expect(evaluateCell("A1", { A1: "=TEXTJOIN(A2, A3, A4:A6)", A2: "COU", A3: "FALSE" })).toBe(
|
|
603
|
+
"COUCOU"
|
|
604
|
+
);
|
|
605
|
+
expect(evaluateCell("A1", { A1: "=TEXTJOIN(A2, A3, A4:A6)", A3: "TRUE" })).toBe("");
|
|
606
|
+
expect(evaluateCell("A1", { A1: "=TEXTJOIN(A2, A3, A4:A6)", A2: "TRO", A4: "L'ÂNE " })).toBe(
|
|
607
|
+
"L'ÂNE TROTRO"
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
//----------------------------------------------------------------------------
|
|
612
|
+
// TRIM
|
|
613
|
+
//----------------------------------------------------------------------------
|
|
614
|
+
|
|
615
|
+
test("TRIM: functional tests on simple arguments", () => {
|
|
616
|
+
expect(evaluateCell("A1", { A1: "=TRIM()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
617
|
+
expect(evaluateCell("A1", { A1: '=TRIM("")' })).toBe("");
|
|
618
|
+
expect(evaluateCell("A1", { A1: '=TRIM(" ")' })).toBe("");
|
|
619
|
+
expect(evaluateCell("A1", { A1: '=TRIM(" Jean Ticonstitutionnalise ")' })).toBe(
|
|
620
|
+
"Jean Ticonstitutionnalise"
|
|
621
|
+
);
|
|
622
|
+
expect(evaluateCell("A1", { A1: '=TRIM(" A ")' })).toBe("A");
|
|
623
|
+
expect(evaluateCell("A1", { A1: '=TRIM(" A ")' })).toBe("A");
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
test("TRIM: casting tests on simple arguments", () => {
|
|
627
|
+
expect(evaluateCell("A1", { A1: "=TRIM(123)" })).toBe("123");
|
|
628
|
+
expect(evaluateCell("A1", { A1: "=TRIM(TRUE)" })).toBe("TRUE");
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
test("TRIM: functional tests on cell arguments", () => {
|
|
632
|
+
expect(evaluateCell("A1", { A1: "=TRIM(A2)" })).toBe("");
|
|
633
|
+
expect(evaluateCell("A1", { A1: "=TRIM(A2)", A2: " Kikou " })).toBe("Kikou");
|
|
634
|
+
expect(evaluateCell("A1", { A1: "=TRIM(A2)", A2: '" Kikou "' })).toBe('" Kikou "');
|
|
635
|
+
expect(evaluateCell("A1", { A1: "=TRIM(A2)", A2: '=" Kikou "' })).toBe("Kikou");
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
//----------------------------------------------------------------------------
|
|
639
|
+
// UPPER
|
|
640
|
+
//----------------------------------------------------------------------------
|
|
641
|
+
|
|
642
|
+
test("UPPER: functional tests on simple arguments", () => {
|
|
643
|
+
expect(evaluateCell("A1", { A1: "=UPPER()" })).toBe("#BAD_EXPR"); // @compatibility: on google sheets, return #N/A
|
|
644
|
+
expect(evaluateCell("A1", { A1: "=UPPER(0)" })).toBe("0");
|
|
645
|
+
expect(evaluateCell("A1", { A1: "=UPPER(42)" })).toBe("42");
|
|
646
|
+
expect(evaluateCell("A1", { A1: '=UPPER("grrrr !")' })).toBe("GRRRR !");
|
|
647
|
+
expect(evaluateCell("A1", { A1: '=UPPER("true")' })).toBe("TRUE");
|
|
648
|
+
expect(evaluateCell("A1", { A1: '=UPPER("false")' })).toBe("FALSE");
|
|
649
|
+
expect(evaluateCell("A1", { A1: '=UPPER("オドゥ")' })).toBe("オドゥ");
|
|
650
|
+
expect(evaluateCell("A1", { A1: '=UPPER("オaドb")' })).toBe("オAドB");
|
|
651
|
+
expect(evaluateCell("A1", { A1: '=UPPER("")' })).toBe("");
|
|
652
|
+
expect(evaluateCell("A1", { A1: '=UPPER(" ")' })).toBe(" ");
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
test("UPPER: functional tests on cell arguments", () => {
|
|
656
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)" })).toBe("");
|
|
657
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: " " })).toBe(" ");
|
|
658
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: "0" })).toBe("0");
|
|
659
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '""' })).toBe('""');
|
|
660
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '" "' })).toBe('" "');
|
|
661
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '"true"' })).toBe('"TRUE"');
|
|
662
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '=""' })).toBe("");
|
|
663
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '=" "' })).toBe(" ");
|
|
664
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '="test"' })).toBe("TEST");
|
|
665
|
+
expect(evaluateCell("A1", { A1: "=UPPER(A2)", A2: '="true"' })).toBe("TRUE");
|
|
666
|
+
});
|
|
667
|
+
});
|