Spaces:
Build error
Build error
File size: 504 Bytes
d9494a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import { mapByProperty } from '@/utils/array/mapByProperty';
describe('mapByProperty', () => {
it('should extract the specified property from an item', () => {
const items = [
{ id: '1', name: 'Alice' },
{ id: '2', name: 'Bob' },
];
expect(items.map(mapByProperty('name'))).toEqual(['Alice', 'Bob']);
});
it('should extract the id property', () => {
const items = [{ id: 'a' }, { id: 'b' }];
expect(items.map(mapByProperty('id'))).toEqual(['a', 'b']);
});
});
|