Files
30-seconds-of-code/test/groupBy.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

12 lines
471 B
JavaScript

const {groupBy} = require('./_30s.js');
test('groupBy is a Function', () => {
expect(groupBy).toBeInstanceOf(Function);
});
test('Groups the elements of an array based on the given function', () => {
expect(groupBy([6.1, 4.2, 6.3], Math.floor)).toEqual({ 4: [4.2], 6: [6.1, 6.3] });
});
test('Groups the elements of an array based on the given function', () => {
expect(groupBy(['one', 'two', 'three'], 'length')).toEqual({ 3: ['one', 'two'], 5: ['three'] });
});