* chore: make aware eslint that we use jest By setting up the jest environment, we no longer need to declare the 'test' global in the configuration. * chore: don't need to import expect, it's a jest environment global * chore: don't need to import expect when creating undefined test
23 lines
486 B
JavaScript
23 lines
486 B
JavaScript
const {reducedFilter} = require('./_30s.js');
|
|
|
|
test('reducedFilter is a Function', () => {
|
|
expect(reducedFilter).toBeInstanceOf(Function);
|
|
});
|
|
const data = [
|
|
{
|
|
id: 1,
|
|
name: 'john',
|
|
age: 24
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'mike',
|
|
age: 50
|
|
}
|
|
];
|
|
test('Filter an array of objects based on a condition while also filtering out unspecified keys.', () => {
|
|
expect(reducedFilter(data, ['id', 'name'], item => item.age > 24)).toEqual([
|
|
{ id: 2, name: 'mike' }
|
|
]);
|
|
});
|