@odoo/o-spreadsheet 14.0.1 → 15.0.0
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 +31302 -0
- package/dist/o_spreadsheet.d.ts +6604 -0
- package/dist/o_spreadsheet.esm.js +31257 -0
- package/dist/o_spreadsheet.iife.js +31304 -0
- package/dist/o_spreadsheet.iife.min.js +3071 -0
- package/package.json +57 -15
- 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,540 +0,0 @@
|
|
|
1
|
-
import { Model } from "../src";
|
|
2
|
-
import { fontSizes } from "../src/fonts";
|
|
3
|
-
import { FullMenuItem, topbarMenuRegistry } from "../src/registries/index";
|
|
4
|
-
import { CommandResult, SpreadsheetEnv } from "../src/types";
|
|
5
|
-
import { GridParent, makeTestFixture, mockUuidV4To, nextTick } from "./helpers";
|
|
6
|
-
jest.mock("../src/helpers/uuid", () => require("./__mocks__/uuid"));
|
|
7
|
-
|
|
8
|
-
function getNode(_path: string[]): FullMenuItem {
|
|
9
|
-
const path = [..._path];
|
|
10
|
-
const root = path.splice(0, 1)[0];
|
|
11
|
-
let node = topbarMenuRegistry.get(root);
|
|
12
|
-
for (let p of path) {
|
|
13
|
-
if (typeof node.children !== "function") {
|
|
14
|
-
node = node.children.find((child) => child.id === p)!;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return node;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function doAction(path: string[], env: SpreadsheetEnv): void {
|
|
21
|
-
const node = getNode(path);
|
|
22
|
-
node.action(env);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function getName(path: string[], env: SpreadsheetEnv): string {
|
|
26
|
-
const node = getNode(path);
|
|
27
|
-
return typeof node.name === "function" ? node.name(env).toString() : node.name.toString();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe("Menu Item Registry", () => {
|
|
31
|
-
let menuDefinitions;
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
menuDefinitions = Object.assign({}, topbarMenuRegistry.content);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
topbarMenuRegistry.content = menuDefinitions;
|
|
38
|
-
});
|
|
39
|
-
test("Can add children to menu Items", () => {
|
|
40
|
-
topbarMenuRegistry.add("root", { name: "Root", sequence: 1 });
|
|
41
|
-
topbarMenuRegistry.addChild("child1", ["root"], { name: "Child1", sequence: 1 });
|
|
42
|
-
topbarMenuRegistry.addChild("child2", ["root", "child1"], { name: "Child2", sequence: 1 });
|
|
43
|
-
const item = topbarMenuRegistry.get("root");
|
|
44
|
-
expect(item.children).toHaveLength(1);
|
|
45
|
-
expect(item.children[0].name).toBe("Child1");
|
|
46
|
-
expect(item.children[0].id).toBe("child1");
|
|
47
|
-
expect(item.children[0].children).toHaveLength(1);
|
|
48
|
-
expect(item.children[0].children[0].name).toBe("Child2");
|
|
49
|
-
expect(item.children[0].children[0].id).toBe("child2");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("Adding a child to non-existing item throws", () => {
|
|
53
|
-
expect(() =>
|
|
54
|
-
topbarMenuRegistry.addChild("child", ["non-existing"], { name: "child", sequence: 1 })
|
|
55
|
-
).toThrow();
|
|
56
|
-
topbarMenuRegistry.add("root", { name: "Root", sequence: 1 });
|
|
57
|
-
expect(() =>
|
|
58
|
-
topbarMenuRegistry.addChild("child1", ["root", "non-existing"], {
|
|
59
|
-
name: "Child1",
|
|
60
|
-
sequence: 1,
|
|
61
|
-
})
|
|
62
|
-
).toThrow();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe("Menu Item actions", () => {
|
|
67
|
-
let fixture: HTMLElement;
|
|
68
|
-
let model: Model;
|
|
69
|
-
let parent: GridParent;
|
|
70
|
-
let env: SpreadsheetEnv;
|
|
71
|
-
|
|
72
|
-
beforeEach(async () => {
|
|
73
|
-
fixture = makeTestFixture();
|
|
74
|
-
model = new Model();
|
|
75
|
-
parent = new GridParent(model);
|
|
76
|
-
env = parent.env;
|
|
77
|
-
await parent.mount(fixture);
|
|
78
|
-
env.dispatch = jest.fn(() => ({ status: "SUCCESS" } as CommandResult));
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("Edit -> undo", () => {
|
|
82
|
-
doAction(["edit", "undo"], env);
|
|
83
|
-
expect(env.dispatch).toHaveBeenCalledWith("UNDO");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test("Edit -> redo", () => {
|
|
87
|
-
doAction(["edit", "redo"], env);
|
|
88
|
-
expect(env.dispatch).toHaveBeenCalledWith("REDO");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("Edit -> copy", () => {
|
|
92
|
-
env.clipboard.writeText = jest.fn(() => Promise.resolve());
|
|
93
|
-
doAction(["edit", "copy"], env);
|
|
94
|
-
expect(env.dispatch).toHaveBeenCalledWith("COPY", {
|
|
95
|
-
target: env.getters.getSelectedZones(),
|
|
96
|
-
});
|
|
97
|
-
expect(env.clipboard.writeText).toHaveBeenCalledWith(env.getters.getClipboardContent());
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("Edit -> cut", () => {
|
|
101
|
-
env.clipboard.writeText = jest.fn(() => Promise.resolve());
|
|
102
|
-
doAction(["edit", "cut"], env);
|
|
103
|
-
expect(env.dispatch).toHaveBeenCalledWith("CUT", {
|
|
104
|
-
target: env.getters.getSelectedZones(),
|
|
105
|
-
});
|
|
106
|
-
expect(env.clipboard.writeText).toHaveBeenCalledWith(env.getters.getClipboardContent());
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("Edit -> paste from OS clipboard if copied from outside world last", async () => {
|
|
110
|
-
doAction(["edit", "copy"], env); // first copy from grid
|
|
111
|
-
await env.clipboard.writeText("Then copy in OS clipboard");
|
|
112
|
-
doAction(["edit", "paste"], env);
|
|
113
|
-
await nextTick();
|
|
114
|
-
expect(env.dispatch).toHaveBeenCalledWith("PASTE_FROM_OS_CLIPBOARD", {
|
|
115
|
-
text: await env.clipboard.readText(),
|
|
116
|
-
target: [{ bottom: 0, left: 0, right: 0, top: 0 }],
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test("Edit -> paste if copied from grid last", async () => {
|
|
121
|
-
await env.clipboard.writeText("First copy in OS clipboard");
|
|
122
|
-
doAction(["edit", "copy"], env); // then copy from grid
|
|
123
|
-
doAction(["edit", "paste"], env);
|
|
124
|
-
await nextTick();
|
|
125
|
-
expect(env.dispatch).toHaveBeenCalledWith("PASTE", {
|
|
126
|
-
interactive: true,
|
|
127
|
-
target: [{ bottom: 0, left: 0, right: 0, top: 0 }],
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test("Edit -> paste_special -> paste_special_value", () => {
|
|
132
|
-
doAction(["edit", "paste_special", "paste_special_value"], env);
|
|
133
|
-
expect(env.dispatch).toHaveBeenCalledWith("PASTE", {
|
|
134
|
-
target: env.getters.getSelectedZones(),
|
|
135
|
-
onlyValue: true,
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test("Edit -> paste_special -> paste_special_format", () => {
|
|
140
|
-
doAction(["edit", "paste_special", "paste_special_format"], env);
|
|
141
|
-
expect(env.dispatch).toHaveBeenCalledWith("PASTE", {
|
|
142
|
-
target: env.getters.getSelectedZones(),
|
|
143
|
-
onlyFormat: true,
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test("Edit -> edit_delete_cell_values", () => {
|
|
148
|
-
doAction(["edit", "edit_delete_cell_values"], env);
|
|
149
|
-
expect(env.dispatch).toHaveBeenCalledWith("DELETE_CONTENT", {
|
|
150
|
-
sheet: env.getters.getActiveSheet(),
|
|
151
|
-
target: env.getters.getSelectedZones(),
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe("Edit -> edit_delete_row", () => {
|
|
156
|
-
const path = ["edit", "edit_delete_row"];
|
|
157
|
-
|
|
158
|
-
test("A selected row", () => {
|
|
159
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
160
|
-
expect(getName(path, env)).toBe("Delete row 5");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test("Multiple selected rows", () => {
|
|
164
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
165
|
-
model.dispatch("SELECT_ROW", { index: 5, updateRange: true });
|
|
166
|
-
expect(getName(path, env)).toBe("Delete rows 5 - 6");
|
|
167
|
-
doAction(path, env);
|
|
168
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_ROWS", {
|
|
169
|
-
sheet: env.getters.getActiveSheet(),
|
|
170
|
-
rows: [4, 5],
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test("A selected cell", () => {
|
|
175
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
176
|
-
expect(getName(path, env)).toBe("Delete row 4");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test("Multiple selected cells", () => {
|
|
180
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
181
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
182
|
-
expect(getName(path, env)).toBe("Delete rows 4 - 5");
|
|
183
|
-
doAction(path, env);
|
|
184
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_ROWS", {
|
|
185
|
-
sheet: env.getters.getActiveSheet(),
|
|
186
|
-
rows: [3, 4],
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
describe("Edit -> edit_delete_column", () => {
|
|
192
|
-
const path = ["edit", "edit_delete_column"];
|
|
193
|
-
|
|
194
|
-
test("A selected column", () => {
|
|
195
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
196
|
-
expect(getName(path, env)).toBe("Delete column E");
|
|
197
|
-
doAction(path, env);
|
|
198
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_COLUMNS", {
|
|
199
|
-
sheet: env.getters.getActiveSheet(),
|
|
200
|
-
columns: [4],
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
test("Multiple selected columns", () => {
|
|
205
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
206
|
-
model.dispatch("SELECT_COLUMN", { index: 5, updateRange: true });
|
|
207
|
-
expect(getName(path, env)).toBe("Delete columns E - F");
|
|
208
|
-
doAction(path, env);
|
|
209
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_COLUMNS", {
|
|
210
|
-
sheet: env.getters.getActiveSheet(),
|
|
211
|
-
columns: [4, 5],
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
test("A selected cell", () => {
|
|
216
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
217
|
-
expect(getName(path, env)).toBe("Delete column D");
|
|
218
|
-
doAction(path, env);
|
|
219
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_COLUMNS", {
|
|
220
|
-
sheet: env.getters.getActiveSheet(),
|
|
221
|
-
columns: [3],
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
test("Multiple selected cells", () => {
|
|
226
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
227
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
228
|
-
expect(getName(path, env)).toBe("Delete columns D - E");
|
|
229
|
-
doAction(path, env);
|
|
230
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("REMOVE_COLUMNS", {
|
|
231
|
-
sheet: env.getters.getActiveSheet(),
|
|
232
|
-
columns: [3, 4],
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
describe("Insert -> Row above", () => {
|
|
238
|
-
const path = ["insert", "insert_row_before"];
|
|
239
|
-
|
|
240
|
-
test("A selected row", () => {
|
|
241
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
242
|
-
expect(getName(path, env)).toBe("Row above");
|
|
243
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
test("Multiple selected rows", () => {
|
|
247
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
248
|
-
model.dispatch("SELECT_ROW", { index: 5, updateRange: true });
|
|
249
|
-
expect(getName(path, env)).toBe("2 Rows above");
|
|
250
|
-
doAction(path, env);
|
|
251
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_ROWS", {
|
|
252
|
-
sheet: env.getters.getActiveSheet(),
|
|
253
|
-
row: 4,
|
|
254
|
-
quantity: 2,
|
|
255
|
-
position: "before",
|
|
256
|
-
});
|
|
257
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
test("A selected column should hide the item", () => {
|
|
261
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
262
|
-
expect(getNode(path).isVisible(env)).toBeFalsy();
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
test("A selected cell", () => {
|
|
266
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
267
|
-
expect(getName(path, env)).toBe("Row above");
|
|
268
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
test("Multiple selected cells", () => {
|
|
272
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
273
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
274
|
-
expect(getName(path, env)).toBe("2 Rows above");
|
|
275
|
-
doAction(path, env);
|
|
276
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_ROWS", {
|
|
277
|
-
sheet: env.getters.getActiveSheet(),
|
|
278
|
-
row: 3,
|
|
279
|
-
quantity: 2,
|
|
280
|
-
position: "before",
|
|
281
|
-
});
|
|
282
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe("Insert -> Row below", () => {
|
|
287
|
-
const path = ["insert", "insert_row_after"];
|
|
288
|
-
|
|
289
|
-
test("A selected row", () => {
|
|
290
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
291
|
-
expect(getName(path, env)).toBe("Row below");
|
|
292
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("Multiple selected rows", () => {
|
|
296
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
297
|
-
model.dispatch("SELECT_ROW", { index: 5, updateRange: true });
|
|
298
|
-
expect(getName(path, env)).toBe("2 Rows below");
|
|
299
|
-
doAction(path, env);
|
|
300
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_ROWS", {
|
|
301
|
-
sheet: env.getters.getActiveSheet(),
|
|
302
|
-
row: 5,
|
|
303
|
-
quantity: 2,
|
|
304
|
-
position: "after",
|
|
305
|
-
});
|
|
306
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
test("A selected column should hide the item", () => {
|
|
310
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
311
|
-
expect(getNode(path).isVisible(env)).toBeFalsy();
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
test("A selected cell", () => {
|
|
315
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
316
|
-
expect(getName(path, env)).toBe("Row below");
|
|
317
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
test("Multiple selected cells", () => {
|
|
321
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
322
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
323
|
-
expect(getName(path, env)).toBe("2 Rows below");
|
|
324
|
-
doAction(path, env);
|
|
325
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_ROWS", {
|
|
326
|
-
sheet: env.getters.getActiveSheet(),
|
|
327
|
-
row: 4,
|
|
328
|
-
quantity: 2,
|
|
329
|
-
position: "after",
|
|
330
|
-
});
|
|
331
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
describe("Insert -> Column left", () => {
|
|
336
|
-
const path = ["insert", "insert_column_before"];
|
|
337
|
-
|
|
338
|
-
test("A selected column", () => {
|
|
339
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
340
|
-
expect(getName(path, env)).toBe("Column left");
|
|
341
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
test("Multiple selected columns", () => {
|
|
345
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
346
|
-
model.dispatch("SELECT_COLUMN", { index: 5, updateRange: true });
|
|
347
|
-
expect(getName(path, env)).toBe("2 Columns left");
|
|
348
|
-
doAction(path, env);
|
|
349
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_COLUMNS", {
|
|
350
|
-
sheet: env.getters.getActiveSheet(),
|
|
351
|
-
column: 4,
|
|
352
|
-
quantity: 2,
|
|
353
|
-
position: "before",
|
|
354
|
-
});
|
|
355
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
test("A selected row should hide the item", () => {
|
|
359
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
360
|
-
expect(getNode(path).isVisible(env)).toBeFalsy();
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test("A selected cell", () => {
|
|
364
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
365
|
-
expect(getName(path, env)).toBe("Column left");
|
|
366
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
test("Multiple selected cells", () => {
|
|
370
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
371
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
372
|
-
expect(getName(path, env)).toBe("2 Columns left");
|
|
373
|
-
doAction(path, env);
|
|
374
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_COLUMNS", {
|
|
375
|
-
sheet: env.getters.getActiveSheet(),
|
|
376
|
-
column: 3,
|
|
377
|
-
quantity: 2,
|
|
378
|
-
position: "before",
|
|
379
|
-
});
|
|
380
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
describe("Insert -> Column right", () => {
|
|
385
|
-
const path = ["insert", "insert_column_after"];
|
|
386
|
-
|
|
387
|
-
test("A selected column", () => {
|
|
388
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
389
|
-
expect(getName(path, env)).toBe("Column right");
|
|
390
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
test("Multiple selected columns", () => {
|
|
394
|
-
model.dispatch("SELECT_COLUMN", { index: 4, createRange: true });
|
|
395
|
-
model.dispatch("SELECT_COLUMN", { index: 5, updateRange: true });
|
|
396
|
-
expect(getName(path, env)).toBe("2 Columns right");
|
|
397
|
-
doAction(path, env);
|
|
398
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_COLUMNS", {
|
|
399
|
-
sheet: env.getters.getActiveSheet(),
|
|
400
|
-
column: 5,
|
|
401
|
-
quantity: 2,
|
|
402
|
-
position: "after",
|
|
403
|
-
});
|
|
404
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
test("A selected row should hide the item", () => {
|
|
408
|
-
model.dispatch("SELECT_ROW", { index: 4, createRange: true });
|
|
409
|
-
expect(getNode(path).isVisible(env)).toBeFalsy();
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
test("A selected cell", () => {
|
|
413
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
414
|
-
expect(getName(path, env)).toBe("Column right");
|
|
415
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
test("Multiple selected cells", () => {
|
|
419
|
-
model.dispatch("SELECT_CELL", { col: 3, row: 3 });
|
|
420
|
-
model.dispatch("ALTER_SELECTION", { cell: [4, 4] });
|
|
421
|
-
expect(getName(path, env)).toBe("2 Columns right");
|
|
422
|
-
doAction(path, env);
|
|
423
|
-
expect(env.dispatch).toHaveBeenLastCalledWith("ADD_COLUMNS", {
|
|
424
|
-
sheet: env.getters.getActiveSheet(),
|
|
425
|
-
column: 4,
|
|
426
|
-
quantity: 2,
|
|
427
|
-
position: "after",
|
|
428
|
-
});
|
|
429
|
-
expect(getNode(path).isVisible(env)).toBeTruthy();
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
test("Insert -> new sheet", () => {
|
|
434
|
-
mockUuidV4To(42);
|
|
435
|
-
doAction(["insert", "insert_sheet"], env);
|
|
436
|
-
expect(env.dispatch).toHaveBeenCalledWith("CREATE_SHEET", { activate: true, id: "42" });
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
describe("Format -> numbers", () => {
|
|
440
|
-
test("Automatic", () => {
|
|
441
|
-
doAction(["format", "format_number", "format_number_auto"], env);
|
|
442
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
443
|
-
sheet: env.getters.getActiveSheet(),
|
|
444
|
-
target: env.getters.getSelectedZones(),
|
|
445
|
-
formatter: "",
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
test("Number", () => {
|
|
450
|
-
doAction(["format", "format_number", "format_number_number"], env);
|
|
451
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
452
|
-
sheet: env.getters.getActiveSheet(),
|
|
453
|
-
target: env.getters.getSelectedZones(),
|
|
454
|
-
formatter: "#,##0.00",
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
test("Percent", () => {
|
|
459
|
-
doAction(["format", "format_number", "format_number_percent"], env);
|
|
460
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
461
|
-
sheet: env.getters.getActiveSheet(),
|
|
462
|
-
target: env.getters.getSelectedZones(),
|
|
463
|
-
formatter: "0.00%",
|
|
464
|
-
});
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
test("Date", () => {
|
|
468
|
-
doAction(["format", "format_number", "format_number_date"], env);
|
|
469
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
470
|
-
sheet: env.getters.getActiveSheet(),
|
|
471
|
-
target: env.getters.getSelectedZones(),
|
|
472
|
-
formatter: "m/d/yyyy",
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
test("Time", () => {
|
|
477
|
-
doAction(["format", "format_number", "format_number_time"], env);
|
|
478
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
479
|
-
sheet: env.getters.getActiveSheet(),
|
|
480
|
-
target: env.getters.getSelectedZones(),
|
|
481
|
-
formatter: "hh:mm:ss a",
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
test("Date time", () => {
|
|
486
|
-
doAction(["format", "format_number", "format_number_date_time"], env);
|
|
487
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
488
|
-
sheet: env.getters.getActiveSheet(),
|
|
489
|
-
target: env.getters.getSelectedZones(),
|
|
490
|
-
formatter: "m/d/yyyy hh:mm:ss",
|
|
491
|
-
});
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
test("Duration", () => {
|
|
495
|
-
doAction(["format", "format_number", "format_number_duration"], env);
|
|
496
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTER", {
|
|
497
|
-
sheet: env.getters.getActiveSheet(),
|
|
498
|
-
target: env.getters.getSelectedZones(),
|
|
499
|
-
formatter: "hhhh:mm:ss",
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
test("Format -> bold", () => {
|
|
505
|
-
doAction(["format", "format_bold"], env);
|
|
506
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTING", {
|
|
507
|
-
sheet: env.getters.getActiveSheet(),
|
|
508
|
-
target: env.getters.getSelectedZones(),
|
|
509
|
-
style: { bold: true },
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
test("Format -> italic", () => {
|
|
514
|
-
doAction(["format", "format_italic"], env);
|
|
515
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTING", {
|
|
516
|
-
sheet: env.getters.getActiveSheet(),
|
|
517
|
-
target: env.getters.getSelectedZones(),
|
|
518
|
-
style: { italic: true },
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
test("Format -> strikethrough", () => {
|
|
523
|
-
doAction(["format", "format_strikethrough"], env);
|
|
524
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTING", {
|
|
525
|
-
sheet: env.getters.getActiveSheet(),
|
|
526
|
-
target: env.getters.getSelectedZones(),
|
|
527
|
-
style: { strikethrough: true },
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
test("Format -> font-size", () => {
|
|
532
|
-
const fontSize = fontSizes[0];
|
|
533
|
-
doAction(["format", "format_font_size", `format_font_size_${fontSize.pt}`], env);
|
|
534
|
-
expect(env.dispatch).toHaveBeenCalledWith("SET_FORMATTING", {
|
|
535
|
-
sheet: env.getters.getActiveSheet(),
|
|
536
|
-
target: env.getters.getSelectedZones(),
|
|
537
|
-
style: { fontSize: fontSize.pt },
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`datasource tests create chart with column datasets 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"data": Object {
|
|
6
|
-
"datasets": Array [
|
|
7
|
-
Object {
|
|
8
|
-
"backgroundColor": "rgb(31,119,180)",
|
|
9
|
-
"borderColor": "rgb(31,119,180)",
|
|
10
|
-
"data": Array [
|
|
11
|
-
10,
|
|
12
|
-
11,
|
|
13
|
-
12,
|
|
14
|
-
],
|
|
15
|
-
"label": "first column dataset",
|
|
16
|
-
"lineTension": 0,
|
|
17
|
-
},
|
|
18
|
-
Object {
|
|
19
|
-
"backgroundColor": "rgb(255,127,14)",
|
|
20
|
-
"borderColor": "rgb(255,127,14)",
|
|
21
|
-
"data": Array [
|
|
22
|
-
20,
|
|
23
|
-
19,
|
|
24
|
-
18,
|
|
25
|
-
],
|
|
26
|
-
"label": "second column dataset",
|
|
27
|
-
"lineTension": 0,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
"labels": Array [
|
|
31
|
-
"P1",
|
|
32
|
-
"P2",
|
|
33
|
-
"P3",
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
"options": Object {
|
|
37
|
-
"animation": Object {
|
|
38
|
-
"duration": 0,
|
|
39
|
-
},
|
|
40
|
-
"elements": Object {
|
|
41
|
-
"line": Object {
|
|
42
|
-
"fill": false,
|
|
43
|
-
},
|
|
44
|
-
"point": Object {
|
|
45
|
-
"hitRadius": 15,
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
"hover": Object {
|
|
49
|
-
"animationDuration": 10,
|
|
50
|
-
},
|
|
51
|
-
"layout": Object {
|
|
52
|
-
"padding": Object {
|
|
53
|
-
"bottom": 10,
|
|
54
|
-
"left": 20,
|
|
55
|
-
"right": 20,
|
|
56
|
-
"top": 10,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
"maintainAspectRatio": false,
|
|
60
|
-
"responsive": true,
|
|
61
|
-
"responsiveAnimationDuration": 0,
|
|
62
|
-
"scales": Object {
|
|
63
|
-
"xAxes": Array [
|
|
64
|
-
Object {
|
|
65
|
-
"ticks": Object {
|
|
66
|
-
"labelOffset": 2,
|
|
67
|
-
"maxRotation": 60,
|
|
68
|
-
"minRotation": 15,
|
|
69
|
-
"padding": 5,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
"yAxes": Array [
|
|
74
|
-
Object {
|
|
75
|
-
"ticks": Object {
|
|
76
|
-
"beginAtZero": true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
"title": Object {
|
|
82
|
-
"display": true,
|
|
83
|
-
"fontSize": 22,
|
|
84
|
-
"fontStyle": "normal",
|
|
85
|
-
"text": "test 1",
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
"type": "line",
|
|
89
|
-
}
|
|
90
|
-
`;
|