Skip to content

Commit

Permalink
chore: add missing unit tests for global metadata provider
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jan 11, 2025
1 parent 94b8cd8 commit fe0f905
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/common/src/core/__tests__/slickDataView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ describe('SlickDatView core file', () => {
dv.setItems(items);
expect(dv.mapRowsToIds([0, 1, 999])).toEqual([4, 3]);
});

it('should work with a custom global item metadata provider provided to the DataView constructor options', () => {
dv = new SlickDataView({
globalItemMetadataProvider: {
getRowMetadata(item, row) {
return `row ${row} with name: ${item.name}`;
},
},
});
const items = [
{ id: 4, name: 'John', age: 20 },
{ id: 3, name: 'Jane', age: 24 },
];
dv.setItems(items);
expect(dv.getItemMetadata(0)).toBe('row 0 with name: John');
expect(dv.getItemMetadata(1)).toBe('row 1 with name: Jane');
});
});

describe('CRUD methods', () => {
Expand Down

0 comments on commit fe0f905

Please sign in to comment.