@svgrid/grid 1.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/LICENSE +33 -0
- package/README.md +39 -0
- package/dist/FlexRender.svelte +96 -0
- package/dist/FlexRender.svelte.d.ts +49 -0
- package/dist/SvGrid.svelte +8742 -0
- package/dist/SvGrid.svelte.d.ts +381 -0
- package/dist/SvGridChart.svelte +653 -0
- package/dist/SvGridChart.svelte.d.ts +25 -0
- package/dist/SvGridChart.test.d.ts +1 -0
- package/dist/SvGridChart.test.js +62 -0
- package/dist/SvGridDropdown.svelte +675 -0
- package/dist/SvGridDropdown.svelte.d.ts +40 -0
- package/dist/a11y.contract.test.d.ts +1 -0
- package/dist/a11y.contract.test.js +39 -0
- package/dist/a11y.d.ts +38 -0
- package/dist/a11y.js +37 -0
- package/dist/a11y.test.d.ts +1 -0
- package/dist/a11y.test.js +44 -0
- package/dist/cell-formatting.d.ts +17 -0
- package/dist/cell-formatting.js +141 -0
- package/dist/cell-formatting.test.d.ts +1 -0
- package/dist/cell-formatting.test.js +234 -0
- package/dist/chart-export.d.ts +14 -0
- package/dist/chart-export.js +112 -0
- package/dist/chart.d.ts +226 -0
- package/dist/chart.js +732 -0
- package/dist/chart.test.d.ts +1 -0
- package/dist/chart.test.js +289 -0
- package/dist/collaboration.d.ts +74 -0
- package/dist/collaboration.js +98 -0
- package/dist/collaboration.test.d.ts +1 -0
- package/dist/collaboration.test.js +65 -0
- package/dist/conditional-formatting.d.ts +91 -0
- package/dist/conditional-formatting.js +170 -0
- package/dist/conditional-formatting.test.d.ts +1 -0
- package/dist/conditional-formatting.test.js +87 -0
- package/dist/core.coverage.test.d.ts +1 -0
- package/dist/core.coverage.test.js +186 -0
- package/dist/core.d.ts +370 -0
- package/dist/core.js +568 -0
- package/dist/core.performance.test.d.ts +1 -0
- package/dist/core.performance.test.js +29 -0
- package/dist/createGrid.svelte.d.ts +6 -0
- package/dist/createGrid.svelte.js +17 -0
- package/dist/createGrid.test.d.ts +1 -0
- package/dist/createGrid.test.js +9 -0
- package/dist/createGridState.svelte.d.ts +3 -0
- package/dist/createGridState.svelte.js +13 -0
- package/dist/editors/cell-editors.d.ts +23 -0
- package/dist/editors/cell-editors.js +97 -0
- package/dist/editors/cell-editors.test.d.ts +1 -0
- package/dist/editors/cell-editors.test.js +75 -0
- package/dist/fill-patterns.d.ts +30 -0
- package/dist/fill-patterns.js +207 -0
- package/dist/fill-patterns.test.d.ts +1 -0
- package/dist/fill-patterns.test.js +81 -0
- package/dist/filtering/excel-filters.d.ts +26 -0
- package/dist/filtering/excel-filters.js +64 -0
- package/dist/filtering/excel-filters.test.d.ts +1 -0
- package/dist/filtering/excel-filters.test.js +116 -0
- package/dist/filtering/locale-filter.test.d.ts +13 -0
- package/dist/filtering/locale-filter.test.js +189 -0
- package/dist/flex-render.d.ts +1 -0
- package/dist/flex-render.js +2 -0
- package/dist/flex-render.test.d.ts +1 -0
- package/dist/flex-render.test.js +142 -0
- package/dist/group-aggregate.test.d.ts +1 -0
- package/dist/group-aggregate.test.js +32 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +27 -0
- package/dist/keyboard.d.ts +8 -0
- package/dist/keyboard.js +91 -0
- package/dist/keyboard.test.d.ts +1 -0
- package/dist/keyboard.test.js +27 -0
- package/dist/merge-objects.d.ts +9 -0
- package/dist/merge-objects.js +28 -0
- package/dist/named-views.d.ts +42 -0
- package/dist/named-views.js +80 -0
- package/dist/named-views.test.d.ts +1 -0
- package/dist/named-views.test.js +57 -0
- package/dist/new-features.test.d.ts +1 -0
- package/dist/new-features.test.js +183 -0
- package/dist/render-component.d.ts +13 -0
- package/dist/render-component.js +14 -0
- package/dist/render-component.test.d.ts +1 -0
- package/dist/render-component.test.js +41 -0
- package/dist/server-data-source.d.ts +76 -0
- package/dist/server-data-source.js +83 -0
- package/dist/server-data-source.test.d.ts +1 -0
- package/dist/server-data-source.test.js +81 -0
- package/dist/sparkline.d.ts +56 -0
- package/dist/sparkline.js +97 -0
- package/dist/sparkline.test.d.ts +1 -0
- package/dist/sparkline.test.js +52 -0
- package/dist/static-functions.d.ts +1 -0
- package/dist/static-functions.js +1 -0
- package/dist/subscribe.d.ts +9 -0
- package/dist/subscribe.js +31 -0
- package/dist/subscribe.test.d.ts +1 -0
- package/dist/subscribe.test.js +93 -0
- package/dist/sv-grid-scrollbar.d.ts +1 -0
- package/dist/sv-grid-scrollbar.js +310 -0
- package/dist/svgrid-wrapper.types.d.ts +341 -0
- package/dist/svgrid-wrapper.types.js +1 -0
- package/dist/svgrid.api-extensions.test.d.ts +14 -0
- package/dist/svgrid.api-extensions.test.js +334 -0
- package/dist/svgrid.api.test.d.ts +15 -0
- package/dist/svgrid.api.test.js +169 -0
- package/dist/svgrid.behavior.test.d.ts +15 -0
- package/dist/svgrid.behavior.test.js +605 -0
- package/dist/svgrid.column-reorder.test.d.ts +15 -0
- package/dist/svgrid.column-reorder.test.js +224 -0
- package/dist/svgrid.features.test.d.ts +1 -0
- package/dist/svgrid.features.test.js +129 -0
- package/dist/svgrid.interaction.test.d.ts +9 -0
- package/dist/svgrid.interaction.test.js +318 -0
- package/dist/svgrid.locale-filtering.test.d.ts +15 -0
- package/dist/svgrid.locale-filtering.test.js +261 -0
- package/dist/svgrid.new-features.wrapper.test.d.ts +1 -0
- package/dist/svgrid.new-features.wrapper.test.js +136 -0
- package/dist/svgrid.row-pinning.test.d.ts +14 -0
- package/dist/svgrid.row-pinning.test.js +250 -0
- package/dist/svgrid.set-filter.test.d.ts +17 -0
- package/dist/svgrid.set-filter.test.js +268 -0
- package/dist/svgrid.wrapper.test.d.ts +1 -0
- package/dist/svgrid.wrapper.test.js +33 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +29 -0
- package/dist/transaction.test.d.ts +1 -0
- package/dist/transaction.test.js +89 -0
- package/dist/virtualization/column-virtualizer.d.ts +20 -0
- package/dist/virtualization/column-virtualizer.js +19 -0
- package/dist/virtualization/column-virtualizer.test.d.ts +1 -0
- package/dist/virtualization/column-virtualizer.test.js +25 -0
- package/dist/virtualization/svelte-virtualizer.svelte.d.ts +11 -0
- package/dist/virtualization/svelte-virtualizer.svelte.js +20 -0
- package/dist/virtualization/types.d.ts +28 -0
- package/dist/virtualization/types.js +1 -0
- package/dist/virtualization/virtualizer.d.ts +13 -0
- package/dist/virtualization/virtualizer.js +232 -0
- package/dist/virtualization/virtualizer.test.d.ts +1 -0
- package/dist/virtualization/virtualizer.test.js +41 -0
- package/package.json +69 -0
- package/src/FlexRender.svelte +96 -0
- package/src/SvGrid.svelte +8742 -0
- package/src/SvGridChart.svelte +653 -0
- package/src/SvGridChart.test.ts +69 -0
- package/src/SvGridDropdown.svelte +675 -0
- package/src/a11y.contract.test.ts +49 -0
- package/src/a11y.test.ts +59 -0
- package/src/a11y.ts +59 -0
- package/src/cell-formatting.test.ts +273 -0
- package/src/cell-formatting.ts +169 -0
- package/src/chart-export.ts +144 -0
- package/src/chart.test.ts +311 -0
- package/src/chart.ts +934 -0
- package/src/collaboration.test.ts +74 -0
- package/src/collaboration.ts +161 -0
- package/src/conditional-formatting.test.ts +107 -0
- package/src/conditional-formatting.ts +239 -0
- package/src/core.coverage.test.ts +230 -0
- package/src/core.performance.test.ts +30 -0
- package/src/core.ts +991 -0
- package/src/createGrid.svelte.ts +42 -0
- package/src/createGrid.test.ts +10 -0
- package/src/createGridState.svelte.ts +17 -0
- package/src/editors/cell-editors.test.ts +80 -0
- package/src/editors/cell-editors.ts +127 -0
- package/src/fill-patterns.test.ts +93 -0
- package/src/fill-patterns.ts +229 -0
- package/src/filtering/excel-filters.test.ts +131 -0
- package/src/filtering/excel-filters.ts +101 -0
- package/src/filtering/locale-filter.test.ts +220 -0
- package/src/flex-render.test.ts +143 -0
- package/src/flex-render.ts +3 -0
- package/src/group-aggregate.test.ts +48 -0
- package/src/index.ts +159 -0
- package/src/keyboard.test.ts +59 -0
- package/src/keyboard.ts +97 -0
- package/src/merge-objects.ts +48 -0
- package/src/named-views.test.ts +66 -0
- package/src/named-views.ts +120 -0
- package/src/new-features.test.ts +217 -0
- package/src/render-component.test.ts +51 -0
- package/src/render-component.ts +28 -0
- package/src/server-data-source.test.ts +88 -0
- package/src/server-data-source.ts +163 -0
- package/src/sparkline.test.ts +59 -0
- package/src/sparkline.ts +164 -0
- package/src/static-functions.ts +11 -0
- package/src/subscribe.test.ts +103 -0
- package/src/subscribe.ts +38 -0
- package/src/sv-grid-scrollbar.ts +347 -0
- package/src/svgrid-wrapper.types.ts +382 -0
- package/src/svgrid.api-extensions.test.ts +362 -0
- package/src/svgrid.api.test.ts +192 -0
- package/src/svgrid.behavior.test.ts +657 -0
- package/src/svgrid.column-reorder.test.ts +234 -0
- package/src/svgrid.features.test.ts +157 -0
- package/src/svgrid.interaction.test.ts +355 -0
- package/src/svgrid.locale-filtering.test.ts +259 -0
- package/src/svgrid.new-features.wrapper.test.ts +164 -0
- package/src/svgrid.row-pinning.test.ts +266 -0
- package/src/svgrid.set-filter.test.ts +270 -0
- package/src/svgrid.wrapper.test.ts +35 -0
- package/src/test-setup.ts +37 -0
- package/src/transaction.test.ts +100 -0
- package/src/virtualization/column-virtualizer.test.ts +27 -0
- package/src/virtualization/column-virtualizer.ts +30 -0
- package/src/virtualization/svelte-virtualizer.svelte.ts +24 -0
- package/src/virtualization/types.ts +30 -0
- package/src/virtualization/virtualizer.test.ts +47 -0
- package/src/virtualization/virtualizer.ts +270 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Targets uncovered branches in core.ts:
|
|
3
|
+
* - row.getAllCells() / cell.getValue() / cell.getContext()
|
|
4
|
+
* - row.getCellValueByColumnId() (both hit + miss path)
|
|
5
|
+
* - sortFns variants (alphanumeric, basic, datetime)
|
|
6
|
+
* - filterFns variants
|
|
7
|
+
* - grouping aggregations
|
|
8
|
+
* - paginated row model edge cases
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, it } from 'vitest'
|
|
11
|
+
import {
|
|
12
|
+
columnFilteringFeature,
|
|
13
|
+
columnGroupingFeature,
|
|
14
|
+
createCoreRowModel,
|
|
15
|
+
createExpandedRowModel,
|
|
16
|
+
createFilteredRowModel,
|
|
17
|
+
createGroupedRowModel,
|
|
18
|
+
createPaginatedRowModel,
|
|
19
|
+
createSortedRowModel,
|
|
20
|
+
createSvGrid,
|
|
21
|
+
filterFns,
|
|
22
|
+
rowExpandingFeature,
|
|
23
|
+
rowPaginationFeature,
|
|
24
|
+
rowSelectionFeature,
|
|
25
|
+
rowSortingFeature,
|
|
26
|
+
sortFns,
|
|
27
|
+
tableFeatures,
|
|
28
|
+
type ColumnDef,
|
|
29
|
+
} from './index'
|
|
30
|
+
import { isFunction } from './core'
|
|
31
|
+
|
|
32
|
+
type Row = { id: number; name: string; team: string; salary: number; born: string }
|
|
33
|
+
|
|
34
|
+
const features = tableFeatures({
|
|
35
|
+
columnFilteringFeature,
|
|
36
|
+
columnGroupingFeature,
|
|
37
|
+
rowExpandingFeature,
|
|
38
|
+
rowPaginationFeature,
|
|
39
|
+
rowSelectionFeature,
|
|
40
|
+
rowSortingFeature,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const data: Row[] = [
|
|
44
|
+
{ id: 1, name: 'Ada', team: 'A', salary: 100, born: '1815-12-10' },
|
|
45
|
+
{ id: 2, name: 'Grace', team: 'B', salary: 200, born: '1906-12-09' },
|
|
46
|
+
{ id: 3, name: 'Alan', team: 'A', salary: 150, born: '1912-06-23' },
|
|
47
|
+
{ id: 4, name: 'Linus', team: 'C', salary: 300, born: '1969-12-28' },
|
|
48
|
+
{ id: 5, name: 'Donald', team: 'A', salary: 90, born: '1938-01-10' },
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const columns: ColumnDef<typeof features, Row>[] = [
|
|
52
|
+
{ field: 'name', header: 'Name' },
|
|
53
|
+
{ field: 'team', header: 'Team' },
|
|
54
|
+
{ field: 'salary', header: 'Salary' },
|
|
55
|
+
{ field: 'born', header: 'Born' },
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
function makeGrid(state?: Record<string, unknown>) {
|
|
59
|
+
return createSvGrid({
|
|
60
|
+
data,
|
|
61
|
+
columns,
|
|
62
|
+
_features: features,
|
|
63
|
+
_rowModels: {
|
|
64
|
+
coreRowModel: createCoreRowModel(),
|
|
65
|
+
filteredRowModel: createFilteredRowModel(),
|
|
66
|
+
sortedRowModel: createSortedRowModel(sortFns),
|
|
67
|
+
groupedRowModel: createGroupedRowModel(),
|
|
68
|
+
expandedRowModel: createExpandedRowModel(),
|
|
69
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
70
|
+
},
|
|
71
|
+
state,
|
|
72
|
+
} as any)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
describe('core - row / cell lazy getters', () => {
|
|
76
|
+
it('exercises row.getAllCells() and cell.getValue()', () => {
|
|
77
|
+
const grid = makeGrid()
|
|
78
|
+
const rows = grid.getRowModel().rows
|
|
79
|
+
expect(rows.length).toBeGreaterThan(0)
|
|
80
|
+
for (const row of rows) {
|
|
81
|
+
const cells = (row as any).getAllCells()
|
|
82
|
+
expect(Array.isArray(cells)).toBe(true)
|
|
83
|
+
for (const cell of cells) {
|
|
84
|
+
const value = (cell as any).getValue()
|
|
85
|
+
expect(value).not.toBeUndefined()
|
|
86
|
+
const ctx = (cell as any).getContext()
|
|
87
|
+
expect(ctx).toBeDefined()
|
|
88
|
+
expect(ctx.row).toBe(row)
|
|
89
|
+
expect(ctx.table).toBe(grid)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('getCellValueByColumnId returns undefined for unknown columns', () => {
|
|
95
|
+
const grid = makeGrid()
|
|
96
|
+
const row = grid.getRowModel().rows[0] as any
|
|
97
|
+
expect(row.getCellValueByColumnId('no-such')).toBeUndefined()
|
|
98
|
+
expect(row.getCellValueByColumnId('name')).toBeDefined()
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('caches cached row reference after first access', () => {
|
|
102
|
+
const grid = makeGrid()
|
|
103
|
+
const a = grid.getRowModel().rows[0] as any
|
|
104
|
+
const b = grid.getRowModel().rows[0] as any
|
|
105
|
+
expect(a).toBe(b)
|
|
106
|
+
const cellsA = a.getAllCells()
|
|
107
|
+
const cellsB = a.getAllCells()
|
|
108
|
+
expect(cellsA).toBe(cellsB) // cache hit
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('core - sortFns variants', () => {
|
|
113
|
+
it('auto comparator uses locale string compare', () => {
|
|
114
|
+
expect(sortFns.auto('apple', 'banana')).toBeLessThan(0)
|
|
115
|
+
expect(sortFns.auto('banana', 'apple')).toBeGreaterThan(0)
|
|
116
|
+
expect(sortFns.auto('apple', 'apple')).toBe(0)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('number comparator is numeric', () => {
|
|
120
|
+
expect(sortFns.number(1, 2)).toBeLessThan(0)
|
|
121
|
+
expect(sortFns.number(2, 1)).toBeGreaterThan(0)
|
|
122
|
+
expect(sortFns.number(1, 1)).toBe(0)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('number comparator coerces null to 0', () => {
|
|
126
|
+
expect(sortFns.number(null, 1)).toBeLessThan(0)
|
|
127
|
+
expect(sortFns.number(null, null)).toBe(0)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('date comparator compares ISO strings', () => {
|
|
131
|
+
expect(sortFns.date('2020-01-01', '2021-01-01')).toBeLessThan(0)
|
|
132
|
+
expect(sortFns.date('2021-01-01', '2020-01-01')).toBeGreaterThan(0)
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
describe('core - filterFns variants', () => {
|
|
137
|
+
it('includesString matches case-insensitive substrings', () => {
|
|
138
|
+
expect(filterFns.includesString('Hello World', 'world')).toBe(true)
|
|
139
|
+
expect(filterFns.includesString('Hello', 'xyz')).toBe(false)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('equals matches identical values', () => {
|
|
143
|
+
expect(filterFns.equals('x', 'x')).toBe(true)
|
|
144
|
+
expect(filterFns.equals('x', 'y')).toBe(false)
|
|
145
|
+
expect(filterFns.equals(1, 1)).toBe(true)
|
|
146
|
+
expect(filterFns.equals(1, '1')).toBe(false)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('all exported filterFns are callable', () => {
|
|
150
|
+
for (const key of Object.keys(filterFns)) {
|
|
151
|
+
expect(typeof (filterFns as any)[key]).toBe('function')
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
describe('core - grouping with aggregations', () => {
|
|
157
|
+
it('grouping by team produces grouped rows', () => {
|
|
158
|
+
const grid = makeGrid({ grouping: ['team'] })
|
|
159
|
+
const rows = grid.getRowModel().rows
|
|
160
|
+
expect(rows.length).toBeGreaterThan(0)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('explicitly expanding a group shows nested rows', () => {
|
|
164
|
+
const grid = makeGrid({
|
|
165
|
+
grouping: ['team'],
|
|
166
|
+
expanded: { group_team_A: true },
|
|
167
|
+
})
|
|
168
|
+
const rows = grid.getRowModel().rows
|
|
169
|
+
expect(rows.length).toBeGreaterThan(0)
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
describe('core - pagination edge cases', () => {
|
|
174
|
+
it('page 0 with size larger than data set returns the whole set', () => {
|
|
175
|
+
const grid = makeGrid({ pagination: { pageIndex: 0, pageSize: 1000 } })
|
|
176
|
+
const rows = grid.getRowModel().rows
|
|
177
|
+
expect(rows.length).toBeLessThanOrEqual(data.length)
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
it('past-the-end page returns an empty rowset', () => {
|
|
181
|
+
const grid = makeGrid({ pagination: { pageIndex: 999, pageSize: 2 } })
|
|
182
|
+
const rows = grid.getRowModel().rows
|
|
183
|
+
expect(rows.length).toBe(0)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('basic page-2 slicing', () => {
|
|
187
|
+
const grid = makeGrid({ pagination: { pageIndex: 1, pageSize: 2 } })
|
|
188
|
+
const rows = grid.getRowModel().rows
|
|
189
|
+
expect(rows.length).toBeLessThanOrEqual(2)
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
describe('core - selection state', () => {
|
|
194
|
+
it('initialises with an empty selection record', () => {
|
|
195
|
+
const grid = makeGrid()
|
|
196
|
+
expect(grid.getState().rowSelection ?? {}).toEqual({})
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('stores a selection set via initial state', () => {
|
|
200
|
+
const grid = makeGrid({ rowSelection: { 'row-0': true } })
|
|
201
|
+
expect(grid.getState().rowSelection).toEqual({ 'row-0': true })
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
describe('isFunction helper', () => {
|
|
206
|
+
it('returns true for functions', () => {
|
|
207
|
+
expect(isFunction(() => 0)).toBe(true)
|
|
208
|
+
expect(isFunction(function () {})).toBe(true)
|
|
209
|
+
})
|
|
210
|
+
it('returns false for non-functions', () => {
|
|
211
|
+
expect(isFunction(null)).toBe(false)
|
|
212
|
+
expect(isFunction(undefined)).toBe(false)
|
|
213
|
+
expect(isFunction('string')).toBe(false)
|
|
214
|
+
expect(isFunction(42)).toBe(false)
|
|
215
|
+
expect(isFunction({})).toBe(false)
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
describe('core - column visibility + leaf columns', () => {
|
|
220
|
+
it('getAllColumns returns one entry per column def', () => {
|
|
221
|
+
const grid = makeGrid()
|
|
222
|
+
expect(grid.getAllColumns().length).toBe(columns.length)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
it('getVisibleLeafColumns reflects columnVisibility state', () => {
|
|
226
|
+
const grid = makeGrid({ columnVisibility: { name: false } })
|
|
227
|
+
const visible = (grid as any).getVisibleLeafColumns?.() ?? grid.getAllColumns()
|
|
228
|
+
expect(Array.isArray(visible)).toBe(true)
|
|
229
|
+
})
|
|
230
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { createCoreRowModel, createSortedRowModel, createSvGrid, sortFns, tableFeatures } from './index'
|
|
3
|
+
|
|
4
|
+
describe('core performance smoke', () => {
|
|
5
|
+
it('handles large synthetic shape with bounded row model call', () => {
|
|
6
|
+
const columns = Array.from({ length: 50 }, (_, index) => ({
|
|
7
|
+
field: `c${index}`,
|
|
8
|
+
editorType: 'number' as const,
|
|
9
|
+
}))
|
|
10
|
+
const data = Array.from({ length: 5000 }, (_, rowIndex) => {
|
|
11
|
+
const row: Record<string, number> = {}
|
|
12
|
+
for (let col = 0; col < 50; col += 1) row[`c${col}`] = rowIndex + col
|
|
13
|
+
return row
|
|
14
|
+
})
|
|
15
|
+
const grid = createSvGrid({
|
|
16
|
+
_features: tableFeatures({}),
|
|
17
|
+
_rowModels: {
|
|
18
|
+
coreRowModel: createCoreRowModel(),
|
|
19
|
+
sortedRowModel: createSortedRowModel(sortFns),
|
|
20
|
+
},
|
|
21
|
+
columns,
|
|
22
|
+
data,
|
|
23
|
+
state: { sorting: [{ id: 'c0', desc: true }, { id: 'c1', desc: false }] },
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const rows = grid.getRowModel().rows
|
|
27
|
+
expect(rows.length).toBe(5000)
|
|
28
|
+
expect(rows[0]?.getCellValueByColumnId('c0')).toBe(4999)
|
|
29
|
+
})
|
|
30
|
+
})
|