Skip to content

Commit b27462c

Browse files
Befkadu1claude
andcommitted
test(table): update tests for updateData with targeted reformat
- Expect updateData (not replaceData) for row content changes - Assert pool.releaseAll is not called for content-only changes - Add test for fillMissingFields patching dropped fields as undefined - Mock updateData to return a Promise and getRow to return reformat Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c722326 commit b27462c

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/components/table/table.spec.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ describe('limel-table data updates', () => {
2626
component = new Table();
2727
(component as any).tabulator = {
2828
replaceData: vi.fn(),
29-
updateData: vi.fn(),
29+
updateData: vi.fn().mockResolvedValue(undefined),
3030
updateOrAddData: vi.fn(),
31+
getRow: vi.fn().mockReturnValue({ reformat: vi.fn() }),
32+
};
33+
(component as any).pool = {
34+
releaseAll: vi.fn(),
3135
};
3236
(component as any).setSelection = vi.fn();
3337
(component as any).initialized = true;
@@ -37,7 +41,7 @@ describe('limel-table data updates', () => {
3741
vi.useRealTimers();
3842
});
3943

40-
it('updates rows without replacing data when row content changes', () => {
44+
it('uses updateData and reformats changed rows when row content changes', () => {
4145
vi.useFakeTimers();
4246

4347
const oldData = [{ id: 1, name: 'John' }];
@@ -49,7 +53,23 @@ describe('limel-table data updates', () => {
4953
const tabulator = (component as any).tabulator;
5054
expect(tabulator.replaceData).not.toHaveBeenCalled();
5155
expect(tabulator.updateData).toHaveBeenCalledWith(newData);
52-
expect(tabulator.updateOrAddData).not.toHaveBeenCalled();
56+
expect((component as any).pool.releaseAll).not.toHaveBeenCalled();
57+
});
58+
59+
it('fills missing fields with undefined when updating rows', () => {
60+
vi.useFakeTimers();
61+
62+
const oldData = [{ id: 1, name: 'John', status: 'unread' }];
63+
const newData = [{ id: 1, name: 'John' }];
64+
65+
(component as any).updateData(newData, oldData);
66+
vi.runAllTimers();
67+
68+
const tabulator = (component as any).tabulator;
69+
expect(tabulator.replaceData).not.toHaveBeenCalled();
70+
expect(tabulator.updateData).toHaveBeenCalledWith([
71+
{ id: 1, name: 'John', status: undefined },
72+
]);
5373
});
5474

5575
it('replaces data when the dataset changes', () => {

0 commit comments

Comments
 (0)