@odoo/o-spreadsheet 14.0.1 → 14.0.3
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/dist/o-spreadsheet.cjs.js +17880 -0
- package/dist/o-spreadsheet.d.ts +4119 -0
- package/dist/o-spreadsheet.esm.js +17845 -0
- package/dist/o-spreadsheet.iife.js +17882 -0
- package/dist/o-spreadsheet.iife.min.js +1446 -0
- package/package.json +32 -9
- package/readme.md +10 -0
- package/.eslintrc.json +0 -20
- package/.husky/post-checkout +0 -9
- package/.husky/pre-commit +0 -39
- package/.prettierignore +0 -1
- package/astToFormula.patch +0 -0
- package/demo/data.js +0 -255
- package/demo/index.html +0 -9
- package/demo/libs/Chart.bundle.js +0 -20755
- package/demo/main.js +0 -101
- package/doc/readme.md +0 -46
- package/rollup.config.js +0 -23
- package/src/base_plugin.ts +0 -102
- package/src/components/autofill.ts +0 -146
- package/src/components/bottom_bar.ts +0 -199
- package/src/components/color_picker.ts +0 -150
- package/src/components/composer/autocomplete_dropdown.ts +0 -135
- package/src/components/composer/composer.ts +0 -487
- package/src/components/composer/content_editable_helper.ts +0 -146
- package/src/components/figures/chart.ts +0 -70
- package/src/components/figures/container.ts +0 -268
- package/src/components/figures/text_figure.ts +0 -36
- package/src/components/grid.ts +0 -635
- package/src/components/helpers/dom_helpers.ts +0 -7
- package/src/components/helpers/drag_and_drop.ts +0 -17
- package/src/components/icons.ts +0 -36
- package/src/components/index.ts +0 -1
- package/src/components/menu.ts +0 -288
- package/src/components/overlay.ts +0 -457
- package/src/components/scrollbar.ts +0 -22
- package/src/components/selection_input.ts +0 -168
- package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
- package/src/components/side_panel/chart_panel.ts +0 -104
- package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
- package/src/components/side_panel/conditional_formatting.ts +0 -396
- package/src/components/side_panel/side_panel.ts +0 -127
- package/src/components/side_panel/translations_terms.ts +0 -45
- package/src/components/spreadsheet.ts +0 -198
- package/src/components/top_bar.ts +0 -535
- package/src/constants.ts +0 -26
- package/src/data.ts +0 -149
- package/src/fonts.ts +0 -41
- package/src/formulas/compiler.ts +0 -258
- package/src/formulas/composer_tokenizer.ts +0 -70
- package/src/formulas/index.ts +0 -15
- package/src/formulas/normalize.ts +0 -52
- package/src/formulas/parser.ts +0 -280
- package/src/formulas/range_tokenizer.ts +0 -97
- package/src/formulas/tokenizer.ts +0 -242
- package/src/functions/arguments.ts +0 -114
- package/src/functions/dates.ts +0 -302
- package/src/functions/helpers.ts +0 -592
- package/src/functions/index.ts +0 -52
- package/src/functions/module_database.ts +0 -282
- package/src/functions/module_date.ts +0 -743
- package/src/functions/module_info.ts +0 -69
- package/src/functions/module_logical.ts +0 -208
- package/src/functions/module_lookup.ts +0 -185
- package/src/functions/module_math.ts +0 -1252
- package/src/functions/module_operators.ts +0 -291
- package/src/functions/module_statistical.ts +0 -882
- package/src/functions/module_text.ts +0 -370
- package/src/helpers/color.ts +0 -30
- package/src/helpers/coordinates.ts +0 -71
- package/src/helpers/grid_manipulation.ts +0 -68
- package/src/helpers/index.ts +0 -7
- package/src/helpers/misc.ts +0 -76
- package/src/helpers/numbers.ts +0 -117
- package/src/helpers/uuid.ts +0 -19
- package/src/helpers/zones.ts +0 -263
- package/src/history.ts +0 -186
- package/src/index.ts +0 -84
- package/src/model.ts +0 -261
- package/src/plugins/autofill.ts +0 -412
- package/src/plugins/chart.ts +0 -404
- package/src/plugins/clipboard.ts +0 -461
- package/src/plugins/conditional_format.ts +0 -445
- package/src/plugins/core.ts +0 -1502
- package/src/plugins/edition.ts +0 -157
- package/src/plugins/evaluation.ts +0 -428
- package/src/plugins/figures.ts +0 -123
- package/src/plugins/formatting.ts +0 -630
- package/src/plugins/highlight.ts +0 -187
- package/src/plugins/index.ts +0 -32
- package/src/plugins/merge.ts +0 -524
- package/src/plugins/renderer.ts +0 -571
- package/src/plugins/selection.ts +0 -562
- package/src/plugins/selection_inputs.ts +0 -326
- package/src/registries/autofill_modifiers.ts +0 -76
- package/src/registries/autofill_rules.ts +0 -98
- package/src/registries/figure_registry.ts +0 -30
- package/src/registries/index.ts +0 -7
- package/src/registries/menu_items_registry.ts +0 -110
- package/src/registries/menus/cell_menu_registry.ts +0 -79
- package/src/registries/menus/col_menu_registry.ts +0 -63
- package/src/registries/menus/index.ts +0 -6
- package/src/registries/menus/menu_items_actions.ts +0 -425
- package/src/registries/menus/row_menu_registry.ts +0 -63
- package/src/registries/menus/sheet_menu_registry.ts +0 -75
- package/src/registries/menus/topbar_menu_registry.ts +0 -204
- package/src/registries/side_panel_registry.ts +0 -26
- package/src/registries/topbar_component_registry.ts +0 -12
- package/src/registry.ts +0 -51
- package/src/translation.ts +0 -44
- package/src/types/autofill.ts +0 -48
- package/src/types/chart.ts +0 -26
- package/src/types/commands.ts +0 -716
- package/src/types/conditional_formatting.ts +0 -124
- package/src/types/env.ts +0 -13
- package/src/types/functions.ts +0 -35
- package/src/types/getters.ts +0 -103
- package/src/types/index.ts +0 -20
- package/src/types/misc.ts +0 -143
- package/src/types/rendering.ts +0 -41
- package/src/types/workbook_data.ts +0 -62
- package/tests/__mocks__/uuid.ts +0 -7
- package/tests/canvas.mock.ts +0 -34
- package/tests/components/__mocks__/content_editable_helper.ts +0 -79
- package/tests/components/__mocks__/scrollbar.ts +0 -18
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
- package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
- package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
- package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
- package/tests/components/autocomplete_dropdown_test.ts +0 -315
- package/tests/components/autofill_test.ts +0 -167
- package/tests/components/bottom_bar_test.ts +0 -262
- package/tests/components/chart_side_panel_test.ts +0 -123
- package/tests/components/composer_test.ts +0 -400
- package/tests/components/context_menu_test.ts +0 -825
- package/tests/components/grid_manipulation_test.ts +0 -163
- package/tests/components/grid_test.ts +0 -581
- package/tests/components/overlay_test.ts +0 -541
- package/tests/components/selection_input_test.ts +0 -259
- package/tests/components/side_panel_test.ts +0 -148
- package/tests/components/spreadsheet_test.ts +0 -194
- package/tests/components/top_bar_test.ts +0 -427
- package/tests/data_test.ts +0 -175
- package/tests/dom_helper.ts +0 -42
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
- package/tests/formulas/compiler_test.ts +0 -266
- package/tests/formulas/composer_tokenizer_test.ts +0 -137
- package/tests/formulas/expressions_test.ts +0 -57
- package/tests/formulas/formulas_test.ts +0 -80
- package/tests/formulas/normalize_test.ts +0 -82
- package/tests/formulas/parser_test.ts +0 -224
- package/tests/formulas/range_tokenizer_test.ts +0 -187
- package/tests/formulas/tokenizer_test.ts +0 -164
- package/tests/functions/arguments_test.ts +0 -141
- package/tests/functions/dates_test.ts +0 -1081
- package/tests/functions/functions_test.ts +0 -53
- package/tests/functions/helper_test.ts +0 -98
- package/tests/functions/module_database_test.ts +0 -311
- package/tests/functions/module_date_test.ts +0 -941
- package/tests/functions/module_info_test.ts +0 -139
- package/tests/functions/module_logical_test.ts +0 -369
- package/tests/functions/module_lookup_test.ts +0 -541
- package/tests/functions/module_math_test.ts +0 -2482
- package/tests/functions/module_operators_test.ts +0 -955
- package/tests/functions/module_statistical_test.ts +0 -2014
- package/tests/functions/module_text_test.ts +0 -667
- package/tests/helpers/coordinates_test.ts +0 -25
- package/tests/helpers/misc_test.ts +0 -95
- package/tests/helpers/numbers_test.ts +0 -196
- package/tests/helpers/zones_test.ts +0 -97
- package/tests/helpers.ts +0 -384
- package/tests/menu_items_registry_test.ts +0 -540
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
- package/tests/model/plugins/chart_test.ts +0 -562
- package/tests/model_test.ts +0 -82
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
- package/tests/plugins/autofill_test.ts +0 -457
- package/tests/plugins/borders_test.ts +0 -295
- package/tests/plugins/clipboard_test.ts +0 -1180
- package/tests/plugins/conditional_formatting_test.ts +0 -1253
- package/tests/plugins/core_test.ts +0 -614
- package/tests/plugins/edition_test.ts +0 -100
- package/tests/plugins/evaluation_async_test.ts +0 -332
- package/tests/plugins/evaluation_dates_test.ts +0 -79
- package/tests/plugins/evaluation_test.ts +0 -901
- package/tests/plugins/figures_test.ts +0 -327
- package/tests/plugins/formatting_test.ts +0 -391
- package/tests/plugins/grid_manipulation_test.ts +0 -1366
- package/tests/plugins/highlight_test.ts +0 -413
- package/tests/plugins/history_test.ts +0 -142
- package/tests/plugins/import_export_test.ts +0 -276
- package/tests/plugins/merges_test.ts +0 -490
- package/tests/plugins/navigation_test.ts +0 -181
- package/tests/plugins/plugins/evaluation_test.ts +0 -111
- package/tests/plugins/renderer_test.ts +0 -598
- package/tests/plugins/resizing_test.ts +0 -152
- package/tests/plugins/selection_input_test.ts +0 -409
- package/tests/plugins/selection_test.ts +0 -442
- package/tests/plugins/sheets_test.ts +0 -643
- package/tests/plugins/style_test.ts +0 -90
- package/tsconfig.json +0 -22
|
@@ -1,667 +0,0 @@
|
|
|
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
|
-
});
|