I have the following method that is removing duplicates from an array based on a given property:
removeDuplicates(myArr, prop) {
return myArr.filter((object, pos, arr) => {
return arr.map(obj => obj[prop]).indexOf(object[prop]) === pos;
});
}
Now I need to unit test this method, but I don't know how.
describe('remove duplicates', () => {
it('should remove duplicated objects from an array based on a property', () => {
//..
}
});
How can I properly test methods like this?