@cc-heart/utils
Version:
🔧 javascript common tools collection
41 lines (37 loc) • 1.17 kB
text/typescript
import {
diffCollection,
multipleSelectFilter,
} from '../../../../../integrations/antd/table/checkboxSelect'
describe('diffCollection', () => {
it('should return an empty array if the two collections are the same', () => {
expect(diffCollection([], [])).toEqual([])
})
it('should return an array of elements that are present in one array but not the other', () => {
expect(diffCollection(['a', 'b'], ['a', 'c'])).toEqual(['b', 'c'])
})
})
describe('checkboxSelectFilter', () => {
it('should return an empty array if the two collections are the same', () => {
expect(multipleSelectFilter([], [], [], [], 'id')).toEqual([])
})
it('should return an array of elements that are present in one array but not the other', () => {
expect(
multipleSelectFilter(
['11818', '11812'],
['11818', '11212'],
[
{ id: '11818', name: 'a' },
{ id: '11812', name: 'b' },
],
[
{ id: '11818', name: 'a' },
{ id: '11212', name: 'c' },
],
'id',
),
).toEqual([
{ id: '11818', name: 'a' },
{ id: '11212', name: 'c' },
])
})
})