Files
30-seconds-of-code/test/reducedFilter.test.js
Christian C. Salvadó 83a6a6ea32 [ENHANCEMENT] Properly configure eslint to work with jest (#988)
* 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
2019-06-18 08:34:45 +03:00

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' }
]);
});