@svgrid/grid 1.1.2 → 1.2.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.
Files changed (143) hide show
  1. package/dist/SvGrid.css +294 -16
  2. package/dist/SvGrid.svelte +4 -1
  3. package/dist/SvGridDropdown.svelte +7 -3
  4. package/dist/cdn/svgrid.js +13506 -0
  5. package/dist/cdn/svgrid.svelte-external.js +11190 -0
  6. package/package.json +12 -2
  7. package/src/SvGrid.css +294 -16
  8. package/src/SvGrid.svelte +4 -1
  9. package/src/SvGridDropdown.svelte +7 -3
  10. package/dist/SvGrid.helpers.test.d.ts +0 -1
  11. package/dist/SvGrid.helpers.test.js +0 -298
  12. package/dist/SvGridChart.test.d.ts +0 -1
  13. package/dist/SvGridChart.test.js +0 -62
  14. package/dist/a11y.contract.test.d.ts +0 -1
  15. package/dist/a11y.contract.test.js +0 -39
  16. package/dist/a11y.test.d.ts +0 -1
  17. package/dist/a11y.test.js +0 -44
  18. package/dist/aligned-grids.test.d.ts +0 -1
  19. package/dist/aligned-grids.test.js +0 -75
  20. package/dist/build-api.coverage.test.d.ts +0 -20
  21. package/dist/build-api.coverage.test.js +0 -505
  22. package/dist/cell-formatting.test.d.ts +0 -1
  23. package/dist/cell-formatting.test.js +0 -234
  24. package/dist/cell-render.test.d.ts +0 -1
  25. package/dist/cell-render.test.js +0 -338
  26. package/dist/chart-export.test.d.ts +0 -1
  27. package/dist/chart-export.test.js +0 -302
  28. package/dist/chart.coverage.test.d.ts +0 -1
  29. package/dist/chart.coverage.test.js +0 -748
  30. package/dist/chart.test.d.ts +0 -1
  31. package/dist/chart.test.js +0 -289
  32. package/dist/clipboard.test.d.ts +0 -1
  33. package/dist/clipboard.test.js +0 -700
  34. package/dist/collaboration.coverage.test.d.ts +0 -1
  35. package/dist/collaboration.coverage.test.js +0 -200
  36. package/dist/collaboration.test.d.ts +0 -1
  37. package/dist/collaboration.test.js +0 -65
  38. package/dist/column-groups.test.d.ts +0 -1
  39. package/dist/column-groups.test.js +0 -56
  40. package/dist/column-types.test.d.ts +0 -1
  41. package/dist/column-types.test.js +0 -62
  42. package/dist/columns.test.d.ts +0 -1
  43. package/dist/columns.test.js +0 -625
  44. package/dist/conditional-formatting.test.d.ts +0 -1
  45. package/dist/conditional-formatting.test.js +0 -87
  46. package/dist/core.coverage.test.d.ts +0 -1
  47. package/dist/core.coverage.test.js +0 -186
  48. package/dist/core.performance.test.d.ts +0 -1
  49. package/dist/core.performance.test.js +0 -29
  50. package/dist/createGrid.test.d.ts +0 -1
  51. package/dist/createGrid.test.js +0 -9
  52. package/dist/editing.test.d.ts +0 -1
  53. package/dist/editing.test.js +0 -732
  54. package/dist/editors/cell-editors.coverage.test.d.ts +0 -1
  55. package/dist/editors/cell-editors.coverage.test.js +0 -139
  56. package/dist/editors/cell-editors.test.d.ts +0 -1
  57. package/dist/editors/cell-editors.test.js +0 -75
  58. package/dist/facet-buckets.test.d.ts +0 -1
  59. package/dist/facet-buckets.test.js +0 -296
  60. package/dist/fill-patterns.test.d.ts +0 -1
  61. package/dist/fill-patterns.test.js +0 -81
  62. package/dist/filter-operators.test.d.ts +0 -1
  63. package/dist/filter-operators.test.js +0 -135
  64. package/dist/filtering/excel-filters.test.d.ts +0 -1
  65. package/dist/filtering/excel-filters.test.js +0 -116
  66. package/dist/filtering/locale-filter.test.d.ts +0 -13
  67. package/dist/filtering/locale-filter.test.js +0 -189
  68. package/dist/flex-render.test.d.ts +0 -1
  69. package/dist/flex-render.test.js +0 -142
  70. package/dist/group-aggregate.test.d.ts +0 -1
  71. package/dist/group-aggregate.test.js +0 -32
  72. package/dist/hyperformula-adapter.test.d.ts +0 -1
  73. package/dist/hyperformula-adapter.test.js +0 -205
  74. package/dist/keyboard-handlers.coverage.test.d.ts +0 -1
  75. package/dist/keyboard-handlers.coverage.test.js +0 -495
  76. package/dist/keyboard.test.d.ts +0 -1
  77. package/dist/keyboard.test.js +0 -27
  78. package/dist/menus.test.d.ts +0 -1
  79. package/dist/menus.test.js +0 -560
  80. package/dist/named-views.coverage.test.d.ts +0 -1
  81. package/dist/named-views.coverage.test.js +0 -180
  82. package/dist/named-views.test.d.ts +0 -1
  83. package/dist/named-views.test.js +0 -57
  84. package/dist/new-features.test.d.ts +0 -1
  85. package/dist/new-features.test.js +0 -183
  86. package/dist/render-component.test.d.ts +0 -1
  87. package/dist/render-component.test.js +0 -41
  88. package/dist/row-drag.test.d.ts +0 -1
  89. package/dist/row-drag.test.js +0 -142
  90. package/dist/row-resize.test.d.ts +0 -1
  91. package/dist/row-resize.test.js +0 -329
  92. package/dist/scroll-sync.test.d.ts +0 -1
  93. package/dist/scroll-sync.test.js +0 -290
  94. package/dist/selection.multi-range.test.d.ts +0 -1
  95. package/dist/selection.multi-range.test.js +0 -55
  96. package/dist/selection.test.d.ts +0 -1
  97. package/dist/selection.test.js +0 -647
  98. package/dist/server-data-source.coverage.test.d.ts +0 -1
  99. package/dist/server-data-source.coverage.test.js +0 -154
  100. package/dist/server-data-source.test.d.ts +0 -1
  101. package/dist/server-data-source.test.js +0 -81
  102. package/dist/sparkline.test.d.ts +0 -1
  103. package/dist/sparkline.test.js +0 -52
  104. package/dist/spreadsheet.test.d.ts +0 -1
  105. package/dist/spreadsheet.test.js +0 -446
  106. package/dist/subscribe.test.d.ts +0 -1
  107. package/dist/subscribe.test.js +0 -93
  108. package/dist/svgrid.api-extensions.test.d.ts +0 -14
  109. package/dist/svgrid.api-extensions.test.js +0 -334
  110. package/dist/svgrid.api.test.d.ts +0 -15
  111. package/dist/svgrid.api.test.js +0 -169
  112. package/dist/svgrid.behavior.test.d.ts +0 -15
  113. package/dist/svgrid.behavior.test.js +0 -625
  114. package/dist/svgrid.column-reorder.test.d.ts +0 -15
  115. package/dist/svgrid.column-reorder.test.js +0 -224
  116. package/dist/svgrid.comments-autocomplete.test.d.ts +0 -1
  117. package/dist/svgrid.comments-autocomplete.test.js +0 -96
  118. package/dist/svgrid.context-menu.test.d.ts +0 -1
  119. package/dist/svgrid.context-menu.test.js +0 -102
  120. package/dist/svgrid.features.test.d.ts +0 -1
  121. package/dist/svgrid.features.test.js +0 -129
  122. package/dist/svgrid.interaction.test.d.ts +0 -9
  123. package/dist/svgrid.interaction.test.js +0 -349
  124. package/dist/svgrid.locale-filtering.test.d.ts +0 -15
  125. package/dist/svgrid.locale-filtering.test.js +0 -261
  126. package/dist/svgrid.new-features.wrapper.test.d.ts +0 -1
  127. package/dist/svgrid.new-features.wrapper.test.js +0 -194
  128. package/dist/svgrid.row-pinning.test.d.ts +0 -14
  129. package/dist/svgrid.row-pinning.test.js +0 -250
  130. package/dist/svgrid.set-filter.test.d.ts +0 -17
  131. package/dist/svgrid.set-filter.test.js +0 -268
  132. package/dist/svgrid.wrapper.test.d.ts +0 -1
  133. package/dist/svgrid.wrapper.test.js +0 -59
  134. package/dist/test-setup.d.ts +0 -1
  135. package/dist/test-setup.js +0 -35
  136. package/dist/transaction.test.d.ts +0 -1
  137. package/dist/transaction.test.js +0 -89
  138. package/dist/virtualization/column-virtualizer.test.d.ts +0 -1
  139. package/dist/virtualization/column-virtualizer.test.js +0 -25
  140. package/dist/virtualization/scroll-scaling.test.d.ts +0 -1
  141. package/dist/virtualization/scroll-scaling.test.js +0 -127
  142. package/dist/virtualization/virtualizer.test.d.ts +0 -1
  143. package/dist/virtualization/virtualizer.test.js +0 -41
@@ -1,505 +0,0 @@
1
- /**
2
- * Coverage-focused behavioral tests for the SvGridApi assembled in
3
- * `build-api.ts`. The existing `svgrid.api.test.ts` / `svgrid.api-extensions
4
- * .test.ts` cover filters, row selection, pagination, navigation, and
5
- * getState/setState. This file exercises the remaining surface:
6
- * - getCellValue / setCellValue
7
- * - selectCells / getSelected
8
- * - addRow(s) / removeRow(s) / applyTransaction
9
- * - addColumn(s) / removeColumn / setColumnVisible / getColumns
10
- * - setColumnWidth / setColumnPinning / setColumnOrder
11
- * - setFacetFilter
12
- * - undo / redo / canUndo / canRedo / clearHistory
13
- * - find (open/close/query/hits)
14
- * - grouping (setGroupBy / expandAllGroups / collapseAllGroups)
15
- * - autosizeColumn / refresh
16
- *
17
- * All tests mount the real <SvGrid /> in jsdom and drive the api handed back
18
- * from onApiReady.
19
- */
20
- import { describe, expect, it } from "vitest";
21
- import { mount, unmount } from "svelte";
22
- import SvGrid from "./SvGrid.svelte";
23
- import { columnFilteringFeature, columnGroupingFeature, rowExpandingFeature, rowSelectionFeature, rowSortingFeature, tableFeatures, } from "./index";
24
- const baseRows = [
25
- { id: 1, name: "Ada Lovelace", team: "Research", salary: 142000 },
26
- { id: 2, name: "Grace Hopper", team: "Compilers", salary: 158000 },
27
- { id: 3, name: "Alan Turing", team: "Research", salary: 138000 },
28
- { id: 4, name: "Margaret Hamilton", team: "Apollo", salary: 165000 },
29
- { id: 5, name: "Linus Torvalds", team: "Kernel", salary: 175000 },
30
- ];
31
- const baseColumns = [
32
- { field: "name", header: "Name", width: 200 },
33
- { field: "team", header: "Team", width: 160 },
34
- { field: "salary", header: "Salary", width: 140 },
35
- ];
36
- const flush = () => Promise.resolve();
37
- function mountGrid(extraProps = {}, features = tableFeatures({
38
- columnFilteringFeature,
39
- rowSortingFeature,
40
- rowSelectionFeature,
41
- columnGroupingFeature,
42
- rowExpandingFeature,
43
- })) {
44
- return new Promise((resolveApi, rejectApi) => {
45
- const target = document.createElement("div");
46
- document.body.appendChild(target);
47
- let captured = null;
48
- const app = mount(SvGrid, {
49
- target,
50
- props: {
51
- data: baseRows.map((r) => ({ ...r })),
52
- columns: baseColumns.map((c) => ({ ...c })),
53
- features,
54
- getRowId: (r) => String(r.id),
55
- rowHeight: 36,
56
- containerHeight: 480,
57
- virtualization: false,
58
- enableCellSelection: true,
59
- onApiReady(api) {
60
- captured = api;
61
- resolveApi({
62
- api,
63
- target,
64
- destroy: () => {
65
- unmount(app);
66
- target.remove();
67
- },
68
- });
69
- },
70
- ...extraProps,
71
- },
72
- });
73
- queueMicrotask(() => {
74
- if (!captured)
75
- rejectApi(new Error("onApiReady never fired"));
76
- });
77
- });
78
- }
79
- describe("SvGridApi - cell read / write", () => {
80
- it("getCellValue reads through the column field", async () => {
81
- const { api, destroy } = await mountGrid();
82
- try {
83
- expect(api.getCellValue(0, "name")).toBe("Ada Lovelace");
84
- expect(api.getCellValue(3, "team")).toBe("Apollo");
85
- }
86
- finally {
87
- destroy();
88
- }
89
- });
90
- it("getCellValue returns undefined for out-of-range row or unknown column", async () => {
91
- const { api, destroy } = await mountGrid();
92
- try {
93
- expect(api.getCellValue(999, "name")).toBeUndefined();
94
- expect(api.getCellValue(0, "nope")).toBeUndefined();
95
- }
96
- finally {
97
- destroy();
98
- }
99
- });
100
- it("setCellValue writes a new immutable row and reads back", async () => {
101
- const { api, destroy } = await mountGrid();
102
- try {
103
- api.setCellValue(0, "name", "Ada L.");
104
- await flush();
105
- expect(api.getCellValue(0, "name")).toBe("Ada L.");
106
- // other rows untouched
107
- expect(api.getCellValue(1, "name")).toBe("Grace Hopper");
108
- }
109
- finally {
110
- destroy();
111
- }
112
- });
113
- it("setCellValue is a no-op for an invalid target", async () => {
114
- const { api, destroy } = await mountGrid();
115
- try {
116
- expect(() => api.setCellValue(999, "name", "x")).not.toThrow();
117
- expect(() => api.setCellValue(0, "unknown", "x")).not.toThrow();
118
- }
119
- finally {
120
- destroy();
121
- }
122
- });
123
- });
124
- describe("SvGridApi - cell selection", () => {
125
- it("selectCells sets a rectangle; getSelected reads it back normalized", async () => {
126
- const { api, destroy } = await mountGrid();
127
- try {
128
- api.selectCells([[2, 1, 0, 0]]); // unsorted corners
129
- await flush();
130
- expect(api.getSelected()).toEqual([[0, 0, 2, 1]]);
131
- }
132
- finally {
133
- destroy();
134
- }
135
- });
136
- it("selectCells clamps open-ended (Infinity) coordinates to grid bounds", async () => {
137
- const { api, destroy } = await mountGrid();
138
- try {
139
- api.selectCells([[0, 0, Infinity, Infinity]]);
140
- await flush();
141
- // 5 rows (0..4), 3 cols (0..2)
142
- expect(api.getSelected()).toEqual([[0, 0, 4, 2]]);
143
- }
144
- finally {
145
- destroy();
146
- }
147
- });
148
- it("empty selectCells clears the range; getSelected returns []", async () => {
149
- const { api, destroy } = await mountGrid();
150
- try {
151
- api.selectCells([[0, 0, 1, 1]]);
152
- await flush();
153
- api.selectCells([]);
154
- await flush();
155
- expect(api.getSelected()).toEqual([]);
156
- }
157
- finally {
158
- destroy();
159
- }
160
- });
161
- });
162
- describe("SvGridApi - row mutations", () => {
163
- it("addRow appends to the bottom by default", async () => {
164
- const { api, destroy } = await mountGrid();
165
- try {
166
- api.addRow({ id: 6, name: "New", team: "QA", salary: 1 });
167
- await flush();
168
- const data = api.getData();
169
- expect(data.length).toBe(6);
170
- expect(data[5].id).toBe(6);
171
- }
172
- finally {
173
- destroy();
174
- }
175
- });
176
- it("addRows at top / numeric index insert in place", async () => {
177
- const { api, destroy } = await mountGrid();
178
- try {
179
- api.addRows([{ id: 7, name: "Top", team: "T", salary: 1 }], "top");
180
- await flush();
181
- expect(api.getData()[0].id).toBe(7);
182
- api.addRows([{ id: 8, name: "Mid", team: "M", salary: 1 }], 2);
183
- await flush();
184
- expect(api.getData()[2].id).toBe(8);
185
- }
186
- finally {
187
- destroy();
188
- }
189
- });
190
- it("removeRow / removeRows drop by index", async () => {
191
- const { api, destroy } = await mountGrid();
192
- try {
193
- api.removeRow(0);
194
- await flush();
195
- expect(api.getData().map((r) => r.id)).toEqual([2, 3, 4, 5]);
196
- api.removeRows([0, 2]); // drops ids 2 and 4
197
- await flush();
198
- expect(api.getData().map((r) => r.id)).toEqual([3, 5]);
199
- }
200
- finally {
201
- destroy();
202
- }
203
- });
204
- it("applyTransaction adds, updates (by id), and removes; returns counts", async () => {
205
- const { api, destroy } = await mountGrid();
206
- try {
207
- const result = api.applyTransaction({
208
- add: [{ id: 9, name: "Added", team: "X", salary: 1 }],
209
- update: [
210
- { id: 2, name: "Grace H.", team: "Compilers", salary: 999 },
211
- ],
212
- remove: ["3"], // by getRowId string
213
- });
214
- await flush();
215
- expect(result).toEqual({ added: 1, updated: 1, removed: 1 });
216
- const data = api.getData();
217
- expect(data.find((r) => r.id === 3)).toBeUndefined();
218
- expect(data.find((r) => r.id === 2).salary).toBe(999);
219
- expect(data.find((r) => r.id === 9)).toBeTruthy();
220
- }
221
- finally {
222
- destroy();
223
- }
224
- });
225
- it("applyTransaction removes by object reference too", async () => {
226
- const { api, destroy } = await mountGrid();
227
- try {
228
- const target = api.getData()[0];
229
- const result = api.applyTransaction({ remove: [target] });
230
- await flush();
231
- expect(result.removed).toBe(1);
232
- expect(api.getData().find((r) => r === target)).toBeUndefined();
233
- }
234
- finally {
235
- destroy();
236
- }
237
- });
238
- });
239
- describe("SvGridApi - column mutations", () => {
240
- it("addColumn left / right / numeric position, then getColumns reflects it", async () => {
241
- const { api, destroy } = await mountGrid();
242
- try {
243
- api.addColumn({ field: "id", header: "ID" }, "left");
244
- await flush();
245
- expect(api.getColumns()[0].id).toBe("id");
246
- api.addColumns([{ field: "extra", header: "Extra" }], "right");
247
- await flush();
248
- const cols = api.getColumns();
249
- expect(cols[cols.length - 1].id).toBe("extra");
250
- }
251
- finally {
252
- destroy();
253
- }
254
- });
255
- it("removeColumn drops a column from the visible set", async () => {
256
- const { api, destroy } = await mountGrid();
257
- try {
258
- api.removeColumn("team");
259
- await flush();
260
- expect(api.getColumns().find((c) => c.id === "team")).toBeUndefined();
261
- }
262
- finally {
263
- destroy();
264
- }
265
- });
266
- it("setColumnVisible toggles visibility; getColumns lists hidden as visible:false", async () => {
267
- const { api, destroy } = await mountGrid();
268
- try {
269
- api.setColumnVisible("team", false);
270
- await flush();
271
- expect(api.isColumnVisible("team")).toBe(false);
272
- const hidden = api.getColumns().find((c) => c.id === "team");
273
- expect(hidden.visible).toBe(false);
274
- api.setColumnVisible("team", true);
275
- await flush();
276
- expect(api.isColumnVisible("team")).toBe(true);
277
- }
278
- finally {
279
- destroy();
280
- }
281
- });
282
- it("setColumnWidth clamps + getColumnWidths round-trips", async () => {
283
- const { api, destroy } = await mountGrid();
284
- try {
285
- api.setColumnWidth("name", 333.7);
286
- await flush();
287
- expect(api.getColumnWidths().name).toBe(333);
288
- }
289
- finally {
290
- destroy();
291
- }
292
- });
293
- it("setColumnPinning dedupes; getColumnPinning returns copies", async () => {
294
- const { api, destroy } = await mountGrid();
295
- try {
296
- api.setColumnPinning({ left: ["name", "name"], right: ["salary"] });
297
- await flush();
298
- const pin = api.getColumnPinning();
299
- expect(pin.left).toEqual(["name"]);
300
- expect(pin.right).toEqual(["salary"]);
301
- // mutating the returned copy doesn't affect internal state
302
- pin.left.push("hacked");
303
- expect(api.getColumnPinning().left).toEqual(["name"]);
304
- }
305
- finally {
306
- destroy();
307
- }
308
- });
309
- it("setColumnOrder + getColumnOrder round-trip", async () => {
310
- const { api, destroy } = await mountGrid();
311
- try {
312
- api.setColumnOrder(["salary", "name", "team"]);
313
- await flush();
314
- expect(api.getColumnOrder().slice(0, 3)).toEqual([
315
- "salary",
316
- "name",
317
- "team",
318
- ]);
319
- }
320
- finally {
321
- destroy();
322
- }
323
- });
324
- // Note: autosizeColumn / autosizeAllColumns are intentionally not asserted
325
- // here - they measure text via real DOM layout (canvas/escape), which jsdom
326
- // does not provide, so they throw in this environment. They are exercised by
327
- // the demo gallery / Playwright suite per the coverage config notes.
328
- });
329
- describe("SvGridApi - facet filter", () => {
330
- it("setFacetFilter narrows displayed rows; null clears it", async () => {
331
- const { api, destroy } = await mountGrid();
332
- try {
333
- api.setFacetFilter("team", ["Research"]);
334
- await flush();
335
- const displayed = api.getDisplayedRows();
336
- expect(displayed.every((r) => r.team === "Research")).toBe(true);
337
- expect(displayed.length).toBe(2);
338
- api.setFacetFilter("team", null);
339
- await flush();
340
- expect(api.getDisplayedRows().length).toBe(5);
341
- }
342
- finally {
343
- destroy();
344
- }
345
- });
346
- it("setFacetFilter with an empty array also clears", async () => {
347
- const { api, destroy } = await mountGrid();
348
- try {
349
- api.setFacetFilter("team", ["Apollo"]);
350
- await flush();
351
- api.setFacetFilter("team", []);
352
- await flush();
353
- expect(api.getDisplayedRows().length).toBe(5);
354
- }
355
- finally {
356
- destroy();
357
- }
358
- });
359
- });
360
- describe("SvGridApi - find", () => {
361
- it("openFind / setFindQuery / getFindHits / closeFind", async () => {
362
- const { api, destroy } = await mountGrid();
363
- try {
364
- api.openFind();
365
- api.setFindQuery("Research");
366
- await flush();
367
- const hits = api.getFindHits();
368
- expect(Array.isArray(hits)).toBe(true);
369
- // two cells contain "Research"
370
- expect(hits.length).toBeGreaterThanOrEqual(2);
371
- api.closeFind();
372
- await flush();
373
- expect(api.getFindHits()).toEqual([]);
374
- }
375
- finally {
376
- destroy();
377
- }
378
- });
379
- });
380
- describe("SvGridApi - undo / redo / history", () => {
381
- it("canUndo is false before any history; undo/redo are no-ops then", async () => {
382
- const { api, destroy } = await mountGrid();
383
- try {
384
- expect(api.canUndo()).toBe(false);
385
- expect(api.canRedo()).toBe(false);
386
- expect(api.undo()).toBe(false);
387
- expect(api.redo()).toBe(false);
388
- }
389
- finally {
390
- destroy();
391
- }
392
- });
393
- it("clearHistory resets the stacks without throwing", async () => {
394
- const { api, destroy } = await mountGrid();
395
- try {
396
- expect(() => api.clearHistory()).not.toThrow();
397
- expect(api.canUndo()).toBe(false);
398
- expect(api.canRedo()).toBe(false);
399
- }
400
- finally {
401
- destroy();
402
- }
403
- });
404
- });
405
- describe("SvGridApi - grouping / expansion", () => {
406
- it("setGroupBy groups rows; the underlying data is unchanged", async () => {
407
- const { api, destroy } = await mountGrid();
408
- try {
409
- api.setGroupBy(["team"]);
410
- await flush();
411
- // Grouping reshapes the display pipeline; the source data is intact.
412
- expect(api.getData().length).toBe(5);
413
- expect(api.getState().grouping).toContain("team");
414
- }
415
- finally {
416
- destroy();
417
- }
418
- });
419
- it("expandAllGroups / collapseAllGroups run without error", async () => {
420
- const { api, destroy } = await mountGrid();
421
- try {
422
- api.setGroupBy(["team"]);
423
- await flush();
424
- expect(() => api.expandAllGroups()).not.toThrow();
425
- await flush();
426
- expect(() => api.collapseAllGroups()).not.toThrow();
427
- await flush();
428
- // un-group
429
- api.setGroupBy([]);
430
- await flush();
431
- expect(api.getData().length).toBe(5);
432
- }
433
- finally {
434
- destroy();
435
- }
436
- });
437
- it("setRowExpanded toggles a row's expanded flag", async () => {
438
- const { api, destroy } = await mountGrid();
439
- try {
440
- expect(() => api.setRowExpanded("1", true)).not.toThrow();
441
- await flush();
442
- expect(() => api.setRowExpanded("1", false)).not.toThrow();
443
- }
444
- finally {
445
- destroy();
446
- }
447
- });
448
- });
449
- describe("SvGridApi - sort opt-out + refresh", () => {
450
- it("setSort with a direction sets a single active clause", async () => {
451
- const { api, destroy } = await mountGrid();
452
- try {
453
- api.setSort("salary", "asc");
454
- await flush();
455
- expect(api.getState().sorting).toEqual([{ id: "salary", desc: false }]);
456
- api.setSort("name", "desc");
457
- await flush();
458
- // Setting a direction replaces the active sort clause.
459
- expect(api.getState().sorting).toEqual([{ id: "name", desc: true }]);
460
- }
461
- finally {
462
- destroy();
463
- }
464
- });
465
- it("setSort with a falsy direction removes that column's clause", async () => {
466
- const { api, destroy } = await mountGrid();
467
- try {
468
- api.setSort("salary", "asc");
469
- await flush();
470
- api.setSort("salary", null);
471
- await flush();
472
- expect(api.getState().sorting.find((s) => s.id === "salary")).toBeUndefined();
473
- }
474
- finally {
475
- destroy();
476
- }
477
- });
478
- it("setSort is ignored for a non-sortable column", async () => {
479
- const { api, destroy } = await mountGrid({
480
- columns: [
481
- { field: "name", header: "Name", width: 200, sortable: false },
482
- { field: "team", header: "Team", width: 160 },
483
- ],
484
- });
485
- try {
486
- api.setSort("name", "asc");
487
- await flush();
488
- expect(api.getState().sorting.find((s) => s.id === "name")).toBeUndefined();
489
- }
490
- finally {
491
- destroy();
492
- }
493
- });
494
- it("refresh re-runs the pipeline without throwing or losing data", async () => {
495
- const { api, destroy } = await mountGrid();
496
- try {
497
- expect(() => api.refresh()).not.toThrow();
498
- await flush();
499
- expect(api.getData().length).toBe(5);
500
- }
501
- finally {
502
- destroy();
503
- }
504
- });
505
- });
@@ -1 +0,0 @@
1
- export {};